Skip to content

Commit

Permalink
fix(initializer): fix bad logic RE argument parsing from the top leve…
Browse files Browse the repository at this point in the history
…l forge command

ISSUES CLOSED: #237
  • Loading branch information
MarshallOfSound committed May 26, 2017
1 parent 8449fb1 commit 774b876
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/electron-forge.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import config from './util/config';

const originalSC = program.executeSubCommand.bind(program);
program.executeSubCommand = (argv, args, unknown) => {
let newArgs = [].concat(args[0]).concat(unknown);
if (args.length > 1) {
newArgs = args.concat('--').concat(args.slice(1));
let indexOfDoubleDash = process.argv.indexOf('--');
indexOfDoubleDash = indexOfDoubleDash < 0 ? process.argv.length + 1 : indexOfDoubleDash;

const passThroughArgs = args.filter(arg => process.argv.indexOf(arg) > indexOfDoubleDash);
const normalArgs = args.filter(arg => process.argv.indexOf(arg) <= indexOfDoubleDash);

let newArgs = args;
let newUnknown = unknown;
if (passThroughArgs.length > 0) {
newArgs = normalArgs.concat(unknown).concat('--').concat(passThroughArgs);
newUnknown = [];
}
return originalSC(argv, newArgs, []);
return originalSC(argv, newArgs, newUnknown);
};

program
Expand Down

0 comments on commit 774b876

Please sign in to comment.