Skip to content

Commit

Permalink
fix(command): Prevent premature resolution during tests from nested c…
Browse files Browse the repository at this point in the history
…ommands
  • Loading branch information
evocateur committed Jul 25, 2018
1 parent 649048c commit 151363f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ class Command {
});

// passed via yargs context in tests, never actual CLI
runner = runner.then(argv.onResolved, argv.onRejected);
/* istanbul ignore else */
if (argv.onResolved || argv.onRejected) {
runner = runner.then(argv.onResolved, argv.onRejected);

// when nested, never resolve inner with outer callbacks
delete argv.onResolved; // eslint-disable-line no-param-reassign
delete argv.onRejected; // eslint-disable-line no-param-reassign
}

// proxy "Promise" methods to "private" instance
this.then = (onResolved, onRejected) => runner.then(onResolved, onRejected);
Expand Down

0 comments on commit 151363f

Please sign in to comment.