Skip to content

Commit a92c9b1

Browse files
committed
chore: resolve the realpath of nodeSourcePath before deleting pchs
nodeSourcePath in Windows refers to a user directory that contains an alias. For example, something like C:\Users\RUNNER~1 (in GHA) while MSVC uses the full name like C:\Users\runneradmin. This can make rimraf not delete the pch files properly. By resolving first, we make sure that both paths are absolute and unambiguous.
1 parent a199a1c commit a92c9b1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,9 @@ async function compileJSFileAsBinaryImpl (options: CompilationOptions, logger: L
473473
// compilations and does not refresh them, but kills the compilation
474474
// process with an error. Due to this, before attempting the second
475475
// compilation, we will delete all pch files.
476-
logger.stepStarting(`(win32) Deleting precompiled headers at ${nodeSourcePath}`);
477-
await rimraf(`${nodeSourcePath}/**/*.pch`, { glob: { follow: true, nodir: true } });
478-
logger.stepCompleted();
479-
logger.stepStarting(`(win32) Deleting precompiled headers at ${options.tmpdir}`);
480-
await rimraf(`${options.tmpdir}/**/*.pch`, { glob: { follow: true, nodir: true } });
476+
const resolvedNodeSourcePath = await fs.realpath(nodeSourcePath);
477+
logger.stepStarting(`(win32) Deleting precompiled headers at ${resolvedNodeSourcePath}`);
478+
await rimraf(`${resolvedNodeSourcePath}/**/*.pch`, { glob: { follow: true, nodir: true } });
481479
logger.stepCompleted();
482480
}
483481
binaryPath = await writeMainFileAndCompile(options.useNodeSnapshot ? {

0 commit comments

Comments
 (0)