chore: fix seed file path windows (#6512)
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
import type { Payload } from 'payload'
|
import type { Payload } from 'payload'
|
||||||
import type { PayloadRequestWithData } from 'payload/types'
|
import type { PayloadRequestWithData } from 'payload/types'
|
||||||
|
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getFileByPath } from 'payload/uploads'
|
import { getFileByPath } from 'payload/uploads'
|
||||||
|
|
||||||
import { mediaSlug } from '../shared.js'
|
import { mediaSlug } from '../shared.js'
|
||||||
|
const filename = fileURLToPath(import.meta.url)
|
||||||
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
export const seed = async (payload: Payload): Promise<boolean> => {
|
export const seed = async (payload: Payload): Promise<boolean> => {
|
||||||
payload.logger.info('Seeding data...')
|
payload.logger.info('Seeding data...')
|
||||||
@@ -12,7 +15,7 @@ export const seed = async (payload: Payload): Promise<boolean> => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create image
|
// Create image
|
||||||
const filePath = path.resolve(process.cwd(), './test/plugin-seo/image-1.jpg')
|
const filePath = path.resolve(dirname, '../image-1.jpg')
|
||||||
const file = await getFileByPath(filePath)
|
const file = await getFileByPath(filePath)
|
||||||
|
|
||||||
const mediaDoc = await payload.create({
|
const mediaDoc = await payload.create({
|
||||||
@@ -24,14 +27,14 @@ export const seed = async (payload: Payload): Promise<boolean> => {
|
|||||||
await payload.create({
|
await payload.create({
|
||||||
collection: 'pages',
|
collection: 'pages',
|
||||||
data: {
|
data: {
|
||||||
title: 'Test Page',
|
|
||||||
slug: 'test-page',
|
slug: 'test-page',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'This is a test meta title',
|
|
||||||
description: 'This is a test meta description',
|
description: 'This is a test meta description',
|
||||||
ogTitle: 'This is a custom og:title field',
|
|
||||||
image: mediaDoc.id,
|
image: mediaDoc.id,
|
||||||
|
ogTitle: 'This is a custom og:title field',
|
||||||
|
title: 'This is a test meta title',
|
||||||
},
|
},
|
||||||
|
title: 'Test Page',
|
||||||
},
|
},
|
||||||
req,
|
req,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user