mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 22:02:53 -04:00
refactor: assign env[PATH] to constant to remove need for ! (#8680)
This commit is contained in:
7
env/path/src/index.ts
vendored
7
env/path/src/index.ts
vendored
@@ -9,10 +9,11 @@ export interface PrependDirsToPathResult {
|
||||
|
||||
export function prependDirsToPath (prependDirs: string[], env = process.env): PrependDirsToPathResult {
|
||||
const prepend = prependDirs.join(path.delimiter)
|
||||
if (env[PATH] != null && (env[PATH] === prepend || env[PATH]!.startsWith(`${prepend}${path.delimiter}`))) {
|
||||
const envPath = env[PATH]
|
||||
if (envPath != null && (envPath === prepend || envPath.startsWith(`${prepend}${path.delimiter}`))) {
|
||||
return {
|
||||
name: PATH,
|
||||
value: env[PATH]!,
|
||||
value: envPath,
|
||||
updated: false,
|
||||
}
|
||||
}
|
||||
@@ -20,7 +21,7 @@ export function prependDirsToPath (prependDirs: string[], env = process.env): Pr
|
||||
name: PATH,
|
||||
value: [
|
||||
prepend,
|
||||
...(env[PATH] != null ? [env[PATH]] : []),
|
||||
...(envPath != null ? [envPath] : []),
|
||||
].join(path.delimiter),
|
||||
updated: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user