From 0a9f5d8eee1779e017725a50606b885bd4974b30 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 11 Mar 2019 17:50:35 -0500 Subject: [PATCH] Pass env as actual env instead of as a flag --- packages/server/src/cli.ts | 4 +--- packages/server/src/vscode/bootstrapFork.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/server/src/cli.ts b/packages/server/src/cli.ts index 5e8ee02c..49706a7c 100644 --- a/packages/server/src/cli.ts +++ b/packages/server/src/cli.ts @@ -33,7 +33,6 @@ export class Entry extends Command { "bootstrap-fork": flags.string({ hidden: true }), "fork": flags.string({ hidden: true }), - env: flags.string({ hidden: true }), args: flags.string({ hidden: true }), }; public static args = [{ @@ -60,7 +59,6 @@ export class Entry extends Command { process.exit(1); } - Object.assign(process.env, flags.env ? JSON.parse(flags.env) : {}); ((flags.args ? JSON.parse(flags.args) : []) as string[]).forEach((arg, i) => { // [0] contains the binary running the script (`node` for example) and // [1] contains the script name, so the arguments come after that. @@ -231,7 +229,7 @@ export class Entry extends Command { logger.info(url); logger.info(" "); - if (flags["open"]) { + if (flags.open) { try { await opn(url); } catch (e) { diff --git a/packages/server/src/vscode/bootstrapFork.ts b/packages/server/src/vscode/bootstrapFork.ts index 8643f3cd..ac097a72 100644 --- a/packages/server/src/vscode/bootstrapFork.ts +++ b/packages/server/src/vscode/bootstrapFork.ts @@ -125,21 +125,21 @@ export const requireModule = (modulePath: string, dataDir: string, builtInExtens */ export const forkModule = (modulePath: string, args: string[], options: cp.ForkOptions, dataDir?: string): cp.ChildProcess => { let proc: cp.ChildProcess; + const forkOptions: cp.ForkOptions = { + stdio: [null, null, null, "ipc"], + }; + if (options.env) { + // This prevents vscode from trying to load original-fs from electron. + delete options.env.ELECTRON_RUN_AS_NODE; + forkOptions.env = options.env; + } const forkArgs = ["--bootstrap-fork", modulePath]; if (args) { forkArgs.push("--args", JSON.stringify(args)); } - if (options.env) { - // This prevents vscode from trying to load original-fs from electron. - delete options.env.ELECTRON_RUN_AS_NODE; - forkArgs.push("--env", JSON.stringify(options.env)); - } if (dataDir) { forkArgs.push("--data-dir", dataDir); } - const forkOptions: cp.ForkOptions = { - stdio: [null, null, null, "ipc"], - }; if (isCli) { proc = cp.spawn(process.execPath, forkArgs, forkOptions); } else {