Skip to content

Commit 0e038aa

Browse files
committed
fix: swallow noisy Vitest error
1 parent 0d8c862 commit 0e038aa

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/vike/src/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,16 @@ async function executeTranspiledFile(filePath: FilePathResolved, code: string) {
372372
// - But seems to break source maps, so I don't think it's worth it
373373
const filePathTmp = getTemporaryBuildFilePath(filePathAbsoluteFilesystem, code)
374374
fs.writeFileSync(filePathTmp, code)
375-
const clean = () => fs.unlinkSync(filePathTmp)
375+
const clean = () => {
376+
try {
377+
fs.unlinkSync(filePathTmp)
378+
} catch {
379+
// I don't know why but with Vitest (4.0.18) it seems that sometimes `filePathTmp` is already removed => we therefore swallow the follow error:
380+
// ```shell
381+
// Error: ENOENT: no such file or directory, unlink '/home/rom/tmp/vike/test/vitest/pages/+config.js.build-4718e6535172.mjs'
382+
// ```
383+
}
384+
}
376385
let fileExports: Record<string, unknown> = {}
377386
try {
378387
fileExports = await executeFile(filePathTmp, filePath)

0 commit comments

Comments
 (0)