summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/child_process.ts
diff options
context:
space:
mode:
authorzuisong <19145952+zuisong@users.noreply.github.com>2023-09-05 18:42:35 +0800
committerGitHub <noreply@github.com>2023-09-05 12:42:35 +0200
commit4a561f12dbae5a49203eb2c08fed71d9d0dfeb99 (patch)
tree15612ee40b52e5ddd24fdecdbf71d6747e8ea476 /ext/node/polyfills/internal/child_process.ts
parent2a1ba2732e5cc04d74837dd9529dbab6e459117c (diff)
fix(node/child_process): don't crash on undefined/null value of an env var (#20378)
Fixes #20373 --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/polyfills/internal/child_process.ts')
-rw-r--r--ext/node/polyfills/internal/child_process.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts
index b11281fd7..33b0b3166 100644
--- a/ext/node/polyfills/internal/child_process.ts
+++ b/ext/node/polyfills/internal/child_process.ts
@@ -53,6 +53,13 @@ export function mapValues<T, O>(
const entries = Object.entries(record);
for (const [key, value] of entries) {
+ if (typeof value === "undefined") {
+ continue;
+ }
+ if (value === null) {
+ continue;
+ }
+
const mappedValue = transformer(value);
ret[key] = mappedValue;
@@ -836,7 +843,7 @@ export function spawnSync(
const output = new Deno.Command(command, {
args,
cwd,
- env,
+ env: mapValues(env, (value) => value.toString()),
stdout: toDenoStdio(normalizedStdio[1]),
stderr: toDenoStdio(normalizedStdio[2]),
uid,