refactor: assign env[PATH] to constant to remove need for ! (#8680)

This commit is contained in:
Brandon Cheng
2024-10-20 21:27:57 -04:00
committed by GitHub
parent 78412f2e4b
commit 1922b4aa3f

View File

@@ -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,
}