Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Fix small bug in CLI #109

Merged
merged 1 commit into from
May 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions electron/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down