@@ -121,6 +121,7 @@ using v8::Value;
121
121
122
122
static bool print_eval = false ;
123
123
static bool force_repl = false ;
124
+ static bool syntax_check_only = false ;
124
125
static bool trace_deprecation = false ;
125
126
static bool throw_deprecation = false ;
126
127
static bool abort_on_uncaught_exception = false ;
@@ -2823,6 +2824,11 @@ void SetupProcessObject(Environment* env,
2823
2824
READONLY_PROPERTY (process, " _print_eval" , True (env->isolate ()));
2824
2825
}
2825
2826
2827
+ // -c, --check
2828
+ if (syntax_check_only) {
2829
+ READONLY_PROPERTY (process, " _syntax_check_only" , True (env->isolate ()));
2830
+ }
2831
+
2826
2832
// -i, --interactive
2827
2833
if (force_repl) {
2828
2834
READONLY_PROPERTY (process, " _forceRepl" , True (env->isolate ()));
@@ -3079,6 +3085,7 @@ static void PrintHelp() {
3079
3085
" -v, --version print Node.js version\n "
3080
3086
" -e, --eval script evaluate script\n "
3081
3087
" -p, --print evaluate script and print result\n "
3088
+ " -c, --check syntax check script without executing\n "
3082
3089
" -i, --interactive always enter the REPL even if stdin\n "
3083
3090
" does not appear to be a terminal\n "
3084
3091
" -r, --require module to preload (option can be repeated)\n "
@@ -3208,6 +3215,8 @@ static void ParseArgs(int* argc,
3208
3215
}
3209
3216
args_consumed += 1 ;
3210
3217
local_preload_modules[preload_module_count++] = module ;
3218
+ } else if (strcmp (arg, " --check" ) == 0 || strcmp (arg, " -c" ) == 0 ) {
3219
+ syntax_check_only = true ;
3211
3220
} else if (strcmp (arg, " --interactive" ) == 0 || strcmp (arg, " -i" ) == 0 ) {
3212
3221
force_repl = true ;
3213
3222
} else if (strcmp (arg, " --no-deprecation" ) == 0 ) {
0 commit comments