Skip to content

Commit 2aa3408

Browse files
committed
Pass process.env using env flags
Also remove redundant env in options Fixes microsoft#134696
1 parent 809becc commit 2aa3408

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/vs/code/node/cli.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ export async function main(argv: string[]): Promise<any> {
404404
}
405405
}
406406

407+
for (const e in env) {
408+
// Ignore the _ env var, because the open command
409+
// ignores it anyway.
410+
// Pass the rest of the env vars in to fix
411+
// https://github.com/microsoft/vscode/issues/134696.
412+
if (e !== '_') {
413+
spawnArgs.push('--env');
414+
spawnArgs.push(`${e}=${env[e]}`);
415+
}
416+
}
417+
407418
spawnArgs.push('--args', ...argv.slice(2)); // pass on our arguments
408419

409420
if (env['VSCODE_DEV']) {
@@ -412,10 +423,23 @@ export async function main(argv: string[]): Promise<any> {
412423
// it needs the full vscode source arg to launch properly.
413424
const curdir = '.';
414425
const launchDirIndex = spawnArgs.indexOf(curdir);
415-
spawnArgs[launchDirIndex] = resolve(curdir);
426+
if (launchDirIndex !== -1) {
427+
spawnArgs[launchDirIndex] = resolve(curdir);
428+
}
416429
}
417430

418-
child = spawn('open', spawnArgs, options);
431+
// Keep just the _ env var here,
432+
// because it's still needed to open Code,
433+
// even though the open command doesn't understand it.
434+
const truncatedOptions = {
435+
detached: options.detached,
436+
stdio: options['stdio'],
437+
env: {
438+
'_': options.env?.['_']
439+
}
440+
};
441+
442+
child = spawn('open', spawnArgs, truncatedOptions);
419443
}
420444

421445
return Promise.all(processCallbacks.map(callback => callback(child)));

0 commit comments

Comments
 (0)