Skip to content

Commit

Permalink
squash: move flag validation to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark committed Apr 1, 2017
1 parent 299155d commit fab87a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
}

if (process._eval != null && !process._forceRepl) {
if (process._syntax_check_only != null) {
console.error('--check and --eval flags are mutually exclusive.');
process.exit(9);
}
// User passed '-e' or '--eval' arguments to Node without '-i' or
// '--interactive'
preloadModules();
Expand Down
6 changes: 6 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3800,6 +3800,12 @@ static void ParseArgs(int* argc,
}
#endif

if (eval_string != nullptr && syntax_check_only) {
fprintf(stderr,
"%s: either --check or --eval can be used, not both\n", argv[0]);
exit(9);
}

// Copy remaining arguments.
const unsigned int args_left = nargs - index;
memcpy(new_argv + new_argc, argv + index, args_left * sizeof(*argv));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ syntaxArgs.forEach(function(args) {

assert.strictEqual(
c.stderr,
'--check and --eval flags are mutually exclusive.\n'
`${node}: either --check or --eval can be used, not both\n`
);

assert.strictEqual(c.status, 9, 'code === ' + c.status);
Expand Down

0 comments on commit fab87a9

Please sign in to comment.