fix(nitro): fix EBUSY error on windows (#425)

This commit is contained in:
pooya parsa 2021-08-09 23:44:50 +02:00 committed by GitHub
parent 4b5d9f1052
commit 3516f40e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,12 +81,20 @@ export function externals (opts: NodeExternalsOptions): Plugin {
}
}
await Promise.all(tracedFiles.map(async (file) => {
const writeFile = async (file) => {
const src = resolve(opts.traceOptions.base, file)
const dst = resolve(opts.outDir, 'node_modules', file.split('node_modules/').pop())
await mkdirp(dirname(dst))
await copyFile(src, dst)
}))
}
if (process.platform === 'win32') {
// Workaround for EBUSY on windows (#424)
for (const file of tracedFiles) {
await writeFile(file)
}
} else {
await Promise.all(tracedFiles.map(writeFile))
}
}
}
}