Skip to content

Commit fab87a9

Browse files
squash: move flag validation to c++
1 parent 299155d commit fab87a9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/internal/bootstrap_node.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@
114114
}
115115

116116
if (process._eval != null && !process._forceRepl) {
117-
if (process._syntax_check_only != null) {
118-
console.error('--check and --eval flags are mutually exclusive.');
119-
process.exit(9);
120-
}
121117
// User passed '-e' or '--eval' arguments to Node without '-i' or
122118
// '--interactive'
123119
preloadModules();

src/node.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,6 +3800,12 @@ static void ParseArgs(int* argc,
38003800
}
38013801
#endif
38023802

3803+
if (eval_string != nullptr && syntax_check_only) {
3804+
fprintf(stderr,
3805+
"%s: either --check or --eval can be used, not both\n", argv[0]);
3806+
exit(9);
3807+
}
3808+
38033809
// Copy remaining arguments.
38043810
const unsigned int args_left = nargs - index;
38053811
memcpy(new_argv + new_argc, argv + index, args_left * sizeof(*argv));

test/parallel/test-cli-syntax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ syntaxArgs.forEach(function(args) {
126126

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

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

0 commit comments

Comments
 (0)