From 1922b4aa3f8daf37cc7cd1fe8dd5cd15ce0844f5 Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Sun, 20 Oct 2024 21:27:57 -0400 Subject: [PATCH] refactor: assign `env[PATH]` to constant to remove need for `!` (#8680) --- env/path/src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/env/path/src/index.ts b/env/path/src/index.ts index 04bb36666a..ae950b1d0c 100644 --- a/env/path/src/index.ts +++ b/env/path/src/index.ts @@ -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, }