Skip to content

Commit 0a9f5d8

Browse files
committed
Pass env as actual env instead of as a flag
1 parent 736feab commit 0a9f5d8

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/server/src/cli.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class Entry extends Command {
3333
"bootstrap-fork": flags.string({ hidden: true }),
3434
"fork": flags.string({ hidden: true }),
3535

36-
env: flags.string({ hidden: true }),
3736
args: flags.string({ hidden: true }),
3837
};
3938
public static args = [{
@@ -60,7 +59,6 @@ export class Entry extends Command {
6059
process.exit(1);
6160
}
6261

63-
Object.assign(process.env, flags.env ? JSON.parse(flags.env) : {});
6462
((flags.args ? JSON.parse(flags.args) : []) as string[]).forEach((arg, i) => {
6563
// [0] contains the binary running the script (`node` for example) and
6664
// [1] contains the script name, so the arguments come after that.
@@ -231,7 +229,7 @@ export class Entry extends Command {
231229
logger.info(url);
232230
logger.info(" ");
233231

234-
if (flags["open"]) {
232+
if (flags.open) {
235233
try {
236234
await opn(url);
237235
} catch (e) {

packages/server/src/vscode/bootstrapFork.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ export const requireModule = (modulePath: string, dataDir: string, builtInExtens
125125
*/
126126
export const forkModule = (modulePath: string, args: string[], options: cp.ForkOptions, dataDir?: string): cp.ChildProcess => {
127127
let proc: cp.ChildProcess;
128-
const forkArgs = ["--bootstrap-fork", modulePath];
129-
if (args) {
130-
forkArgs.push("--args", JSON.stringify(args));
131-
}
128+
const forkOptions: cp.ForkOptions = {
129+
stdio: [null, null, null, "ipc"],
130+
};
132131
if (options.env) {
133132
// This prevents vscode from trying to load original-fs from electron.
134133
delete options.env.ELECTRON_RUN_AS_NODE;
135-
forkArgs.push("--env", JSON.stringify(options.env));
134+
forkOptions.env = options.env;
135+
}
136+
const forkArgs = ["--bootstrap-fork", modulePath];
137+
if (args) {
138+
forkArgs.push("--args", JSON.stringify(args));
136139
}
137140
if (dataDir) {
138141
forkArgs.push("--data-dir", dataDir);
139142
}
140-
const forkOptions: cp.ForkOptions = {
141-
stdio: [null, null, null, "ipc"],
142-
};
143143
if (isCli) {
144144
proc = cp.spawn(process.execPath, forkArgs, forkOptions);
145145
} else {

0 commit comments

Comments
 (0)