Skip to content

Commit af5379b

Browse files
committed
fix(injectEnv): use env == null and ?? check instead of !env, ||
1 parent c3553ba commit af5379b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ export async function injectEnv(config: string | Record<PropertyKey, any>, notFo
1212
let _config: string = isObject ? JSON.stringify(config) : config
1313

1414
_config = _config.replace(/\$\{env:([\w\.]+)\}/g, (_, name) => {
15-
if (!process.env[name]) console.warn(`[injectEnv] env variable ${name} referenced but not found in process.env`)
15+
// Check if null or undefined
16+
if (process.env[name] == null)
17+
console.warn(`[injectEnv] env variable ${name} referenced but not found in process.env`)
1618

17-
return process.env[name] || notFoundValue
19+
return process.env[name] ?? notFoundValue
1820
})
1921

2022
return isObject ? JSON.parse(_config) : _config

0 commit comments

Comments
 (0)