chore: loader tests error on windows (#6508)

This commit is contained in:
Dan Ribbens
2024-05-25 17:57:32 -04:00
committed by GitHub
parent cb14b97a6e
commit 4b6774463e
2 changed files with 6 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { fileURLToPath, pathToFileURL } from 'url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
@@ -17,8 +17,7 @@ export const load = async (filePath) => {
'Looks like payload has not been built. Please run `pnpm build:core` in the monorepo root',
)
}
const importConfigImport = await import(resolvedImportWithoutClientFilesPath)
const importConfigImport = await import(pathToFileURL(resolvedImportWithoutClientFilesPath).href)
const importConfig = importConfigImport.importConfig
const result = await importConfig(filePath)

View File

@@ -1,6 +1,6 @@
import { spawn } from 'node:child_process'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { fileURLToPath, pathToFileURL } from 'node:url'
import path from 'path'
const _filename = fileURLToPath(import.meta.url)
@@ -9,12 +9,12 @@ const _dirname = dirname(_filename)
export const startChildProcess = async (filePath: string): Promise<number> => {
return new Promise<number>((res) => {
const childProcess = spawn('node', [path.resolve(_dirname, 'init.js')], {
stdio: 'inherit',
env: {
PATH: process.env.PATH,
NODE_ENV: 'development',
LOADER_TEST_FILE_PATH: filePath,
NODE_ENV: 'development',
PATH: process.env.PATH,
},
stdio: 'inherit',
})
childProcess.on('close', (code) => {