From 2c2a6498afe6588e1c2221d2fc2d748a5589c919 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 28 May 2020 03:31:11 -0400 Subject: [PATCH] Parse config file in entry This way setting --data-dir and --extension-dir in the config file will work for --install--extension and whatnot. --- src/node/entry.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/node/entry.ts b/src/node/entry.ts index 42907784..53f99d10 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -31,11 +31,7 @@ try { const version = pkg.version || "development" const commit = pkg.commit || "development" -const main = async (cliArgs: Args): Promise => { - const configArgs = await readConfigFile(cliArgs.config) - // This prioritizes the flags set in args over the ones in the config file. - let args = Object.assign(configArgs, cliArgs) - +const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise => { if (!args.auth) { args = { ...args, @@ -145,18 +141,21 @@ function trimLDLibraryPath(): void { async function entry(): Promise { trimLDLibraryPath() - const tryParse = async (): Promise => { + const tryParse = async (): Promise<[Args, Args, Args]> => { try { - let args = parse(process.argv.slice(2)) + const cliArgs = parse(process.argv.slice(2)) + const configArgs = await readConfigFile(cliArgs.config) + // This prioritizes the flags set in args over the ones in the config file. + let args = Object.assign(configArgs, cliArgs) args = await setDefaults(args) - return args + return [args, cliArgs, configArgs] } catch (error) { console.error(error.message) process.exit(1) } } - const args = await tryParse() + const [args, cliArgs, configArgs] = await tryParse() if (args.help) { console.log("code-server", version, commit) console.log("") @@ -200,7 +199,7 @@ async function entry(): Promise { }) vscode.on("exit", (code) => process.exit(code || 0)) } else { - wrap(() => main(args)) + wrap(() => main(args, cliArgs, configArgs)) } }