@@ -34,7 +34,8 @@ Mutex cli_options_mutex;
3434std::shared_ptr<PerProcessOptions> cli_options{new PerProcessOptions ()};
3535} // namespace per_process
3636
37- void DebugOptions::CheckOptions (std::vector<std::string>* errors) {
37+ void DebugOptions::CheckOptions (std::vector<std::string>* errors,
38+ std::vector<std::string>* argv) {
3839#if !NODE_USE_V8_PLATFORM && !HAVE_INSPECTOR
3940 if (inspector_enabled) {
4041 errors->push_back (" Inspector is not available when Node is compiled "
@@ -64,7 +65,8 @@ void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
6465 }
6566}
6667
67- void PerProcessOptions::CheckOptions (std::vector<std::string>* errors) {
68+ void PerProcessOptions::CheckOptions (std::vector<std::string>* errors,
69+ std::vector<std::string>* argv) {
6870#if HAVE_OPENSSL
6971 if (use_openssl_ca && use_bundled_ca) {
7072 errors->push_back (" either --use-openssl-ca or --use-bundled-ca can be "
@@ -91,14 +93,16 @@ void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) {
9193 use_largepages != " silent" ) {
9294 errors->push_back (" invalid value for --use-largepages" );
9395 }
94- per_isolate->CheckOptions (errors);
96+ per_isolate->CheckOptions (errors, argv );
9597}
9698
97- void PerIsolateOptions::CheckOptions (std::vector<std::string>* errors) {
98- per_env->CheckOptions (errors);
99+ void PerIsolateOptions::CheckOptions (std::vector<std::string>* errors,
100+ std::vector<std::string>* argv) {
101+ per_env->CheckOptions (errors, argv);
99102}
100103
101- void EnvironmentOptions::CheckOptions (std::vector<std::string>* errors) {
104+ void EnvironmentOptions::CheckOptions (std::vector<std::string>* errors,
105+ std::vector<std::string>* argv) {
102106 if (has_policy_integrity_string && experimental_policy.empty ()) {
103107 errors->push_back (" --policy-integrity requires "
104108 " --experimental-policy be enabled" );
@@ -169,15 +173,13 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
169173 if (watch_mode) {
170174 if (syntax_check_only) {
171175 errors->push_back (" either --watch or --check can be used, not both" );
172- }
173-
174- if (has_eval_string) {
176+ } else if (has_eval_string) {
175177 errors->push_back (" either --watch or --eval can be used, not both" );
176- }
177-
178- if (force_repl) {
178+ } else if (force_repl) {
179179 errors->push_back (" either --watch or --interactive "
180180 " can be used, not both" );
181+ } else if (argv->size () < 1 || (*argv)[1 ].empty ()) {
182+ errors->push_back (" --watch requires specifying a file" );
181183 }
182184
183185#ifndef ALLOW_ATTACHING_DEBUGGER_IN_WATCH_MODE
@@ -222,7 +224,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
222224 heap_prof_dir = diagnostic_dir;
223225 }
224226
225- debug_options_.CheckOptions (errors);
227+ debug_options_.CheckOptions (errors, argv );
226228#endif // HAVE_INSPECTOR
227229}
228230
0 commit comments