fix(windows): isolate nested repository installs

This commit is contained in:
Tianyi Cui
2026-08-09 15:15:03 +08:00
parent 4a7e51f050
commit 03ba3c506f
3 changed files with 9 additions and 11 deletions

View File

@@ -39,10 +39,14 @@ function scrubEnvironment(environment: NodeJS.ProcessEnv = process.env): NodeJS.
function installEnvironment(commandDirectory: string): NodeJS.ProcessEnv {
const scrubbed = scrubEnvironment()
const path = Object.entries(scrubbed).find(([name]) => name.toUpperCase() === 'PATH')?.[1]
const withoutPath = Object.fromEntries(Object.entries(scrubbed).filter(([name]) => name.toUpperCase() !== 'PATH'))
const withoutOverrides = Object.fromEntries(Object.entries(scrubbed).filter(([name]) => {
return name.toUpperCase() !== 'PATH' && name.toUpperCase() !== 'NPM_CONFIG_IGNORE_WORKSPACE'
}))
return {
...withoutPath,
...withoutOverrides,
PATH: [commandDirectory, ...(path === undefined ? [] : [path])].join(delimiter),
// pnpm prepends its own command directory to lifecycle PATH on Windows.
NPM_CONFIG_IGNORE_WORKSPACE: 'true',
}
}