From 5f63aa8c0709d91e1e91f22329ecb61a5e431563 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Wed, 16 May 2018 14:39:05 +0200 Subject: [PATCH] Make parityArgv simpler --- electron/cli/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/electron/cli/index.js b/electron/cli/index.js index d6b2097f8..50cc38e98 100644 --- a/electron/cli/index.js +++ b/electron/cli/index.js @@ -66,21 +66,26 @@ const camelcase = flag => // Now we must think which arguments passed to cli must be passed down to // parity. const parityArgv = cli.rawArgs - .splice(Math.max(cli.rawArgs.findIndex(item => item.startsWith('--'))), 0) // Remove all arguments until one --option + .splice(2) // Remove first 2 arguments which are program path .filter((item, index, array) => { - const key = camelcase(item.replace('--', '').replace('no-', '')); // Remove first 2 '--' and then camelCase + const key = camelcase(item.replace('--', '').replace('no-', '')); // Remove '--' and then camelCase if (key in cli) { - // If the option is consumed by commander.js, then we skip it + // If the option is consumed by commander.js, then we don't pass down to parity return false; } // If it's not consumed by commander.js, and starts with '--', then we keep - // it. This step is optional, used for optimization only. + // it. if (item.startsWith('--')) { return true; } + // If it's the 1st argument and did not start with --, then we skip it + if (index === 0) { + return false; + } + const previousKey = camelcase(array[index - 1].replace('--', '').replace('no-', '')); if (cli[previousKey] === item) {