Skip to content

Commit 7b61dcc

Browse files
authored
fix: don't use env if not env vars are set (#66)
1 parent 5a5d659 commit 7b61dcc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/shells.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ function runCommandAsUser(
305305
}
306306

307307
// TODO: use a new shell API that natively supports cwd & env
308-
let commandWithEnv = `env ${Object.entries(env ?? {})
309-
.map(([key, value]) => `${key}=${value}`)
310-
.join(" ")} ${command}`;
308+
let commandWithEnv = Object.keys(env ?? {}).length
309+
? `env ${Object.entries(env ?? {})
310+
.map(([key, value]) => `${key}=${value}`)
311+
.join(" ")} ${command}`
312+
: command;
311313

312314
if (cwd) {
313315
commandWithEnv = `cd ${cwd} && ${commandWithEnv}`;

0 commit comments

Comments
 (0)