Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit c597e31

Browse files
fix(exec2): passProcessEnv default to true
1 parent 5ac4224 commit c597e31

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/util/exec2.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Exec2 {
6060
throwOnNonZeroCode = true,
6161
cwd,
6262
env,
63+
passProcessEnv = true,
6364
forceColor = hasColors,
6465
} = opt
6566
let stdout = ''
@@ -72,9 +73,9 @@ class Exec2 {
7273
shell,
7374
cwd,
7475
env: {
75-
...env,
76-
...(opt.passProcessEnv ? process.env : {}),
76+
...(passProcessEnv ? process.env : {}),
7777
...(forceColor ? { FORCE_COLOR: '1' } : {}),
78+
...env,
7879
},
7980
})
8081

@@ -131,7 +132,7 @@ class Exec2 {
131132
spawn(cmd: string, opt: SpawnOptions = {}): void {
132133
const started = Date.now()
133134
this.logStart(cmd, opt)
134-
const { shell = true, cwd, env, forceColor = hasColors } = opt
135+
const { shell = true, cwd, env, passProcessEnv = true, forceColor = hasColors } = opt
135136
console.log('') // 1-line padding before the output
136137

137138
const r = cp.spawnSync(cmd, opt.args, {
@@ -140,9 +141,9 @@ class Exec2 {
140141
shell,
141142
cwd,
142143
env: {
143-
...env,
144-
...(opt.passProcessEnv ? process.env : {}),
144+
...(passProcessEnv ? process.env : {}),
145145
...(forceColor ? { FORCE_COLOR: '1' } : {}),
146+
...env,
146147
},
147148
})
148149

@@ -175,7 +176,7 @@ class Exec2 {
175176
exec(cmd: string, opt: ExecOptions = {}): string {
176177
const started = Date.now()
177178
this.logStart(cmd, opt)
178-
const { cwd, env, timeout } = opt
179+
const { cwd, env, passProcessEnv = true, timeout } = opt
179180

180181
try {
181182
const s = cp
@@ -187,8 +188,8 @@ class Exec2 {
187188
cwd,
188189
timeout,
189190
env: {
191+
...(passProcessEnv ? process.env : {}),
190192
...env,
191-
...(opt.passProcessEnv ? process.env : {}),
192193
},
193194
})
194195
.trim()
@@ -326,8 +327,8 @@ export interface SpawnOptions {
326327

327328
env?: AnyObject
328329
/**
329-
* Defaults to false for security reasons.
330-
* Set to true to pass `process.env` to the spawned process.
330+
* Defaults to true.
331+
* Set to false to NOT pass `process.env` to the spawned process.
331332
*/
332333
passProcessEnv?: boolean
333334
/**

0 commit comments

Comments
 (0)