@@ -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 ;
@@ -2811,6 +2812,11 @@ void SetupProcessObject(Environment* env,
2811
2812
READONLY_PROPERTY (process, " _print_eval" , True (env->isolate ()));
2812
2813
}
2813
2814
2815
+ // -c, --check
2816
+ if (syntax_check_only) {
2817
+ READONLY_PROPERTY (process, " _syntax_check_only" , True (env->isolate ()));
2818
+ }
2819
+
2814
2820
// -i, --interactive
2815
2821
if (force_repl) {
2816
2822
READONLY_PROPERTY (process, " _forceRepl" , True (env->isolate ()));
@@ -3067,6 +3073,7 @@ static void PrintHelp() {
3067
3073
" -v, --version print Node.js version\n "
3068
3074
" -e, --eval script evaluate script\n "
3069
3075
" -p, --print evaluate script and print result\n "
3076
+ " -c, --check syntax check script without executing\n "
3070
3077
" -i, --interactive always enter the REPL even if stdin\n "
3071
3078
" does not appear to be a terminal\n "
3072
3079
" -r, --require module to preload (option can be repeated)\n "
@@ -3196,6 +3203,8 @@ static void ParseArgs(int* argc,
3196
3203
}
3197
3204
args_consumed += 1 ;
3198
3205
local_preload_modules[preload_module_count++] = module ;
3206
+ } else if (strcmp (arg, " --check" ) == 0 || strcmp (arg, " -c" ) == 0 ) {
3207
+ syntax_check_only = true ;
3199
3208
} else if (strcmp (arg, " --interactive" ) == 0 || strcmp (arg, " -i" ) == 0 ) {
3200
3209
force_repl = true ;
3201
3210
} else if (strcmp (arg, " --no-deprecation" ) == 0 ) {
0 commit comments