@@ -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" );
@@ -161,15 +165,13 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
161165 if (watch_mode) {
162166 if (syntax_check_only) {
163167 errors->push_back (" either --watch or --check can be used, not both" );
164- }
165-
166- if (has_eval_string) {
168+ } else if (has_eval_string) {
167169 errors->push_back (" either --watch or --eval can be used, not both" );
168- }
169-
170- if (force_repl) {
170+ } else if (force_repl) {
171171 errors->push_back (" either --watch or --interactive "
172172 " can be used, not both" );
173+ } else if (argv->size () < 1 || (*argv)[1 ].empty ()) {
174+ errors->push_back (" --watch requires specifying a file" );
173175 }
174176
175177#ifndef ALLOW_ATTACHING_DEBUGGER_IN_WATCH_MODE
@@ -214,7 +216,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
214216 heap_prof_dir = diagnostic_dir;
215217 }
216218
217- debug_options_.CheckOptions (errors);
219+ debug_options_.CheckOptions (errors, argv );
218220#endif // HAVE_INSPECTOR
219221}
220222
0 commit comments