@@ -34,7 +34,8 @@ Mutex cli_options_mutex;
34
34
std::shared_ptr<PerProcessOptions> cli_options{new PerProcessOptions ()};
35
35
} // namespace per_process
36
36
37
- void DebugOptions::CheckOptions (std::vector<std::string>* errors) {
37
+ void DebugOptions::CheckOptions (std::vector<std::string>* errors,
38
+ std::vector<std::string>* argv) {
38
39
#if !NODE_USE_V8_PLATFORM && !HAVE_INSPECTOR
39
40
if (inspector_enabled) {
40
41
errors->push_back (" Inspector is not available when Node is compiled "
@@ -64,7 +65,8 @@ void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
64
65
}
65
66
}
66
67
67
- void PerProcessOptions::CheckOptions (std::vector<std::string>* errors) {
68
+ void PerProcessOptions::CheckOptions (std::vector<std::string>* errors,
69
+ std::vector<std::string>* argv) {
68
70
#if HAVE_OPENSSL
69
71
if (use_openssl_ca && use_bundled_ca) {
70
72
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) {
91
93
use_largepages != " silent" ) {
92
94
errors->push_back (" invalid value for --use-largepages" );
93
95
}
94
- per_isolate->CheckOptions (errors);
96
+ per_isolate->CheckOptions (errors, argv );
95
97
}
96
98
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);
99
102
}
100
103
101
- void EnvironmentOptions::CheckOptions (std::vector<std::string>* errors) {
104
+ void EnvironmentOptions::CheckOptions (std::vector<std::string>* errors,
105
+ std::vector<std::string>* argv) {
102
106
if (has_policy_integrity_string && experimental_policy.empty ()) {
103
107
errors->push_back (" --policy-integrity requires "
104
108
" --experimental-policy be enabled" );
@@ -161,15 +165,13 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
161
165
if (watch_mode) {
162
166
if (syntax_check_only) {
163
167
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) {
167
169
errors->push_back (" either --watch or --eval can be used, not both" );
168
- }
169
-
170
- if (force_repl) {
170
+ } else if (force_repl) {
171
171
errors->push_back (" either --watch or --interactive "
172
172
" can be used, not both" );
173
+ } else if (argv->size () < 1 || (*argv)[1 ].empty ()) {
174
+ errors->push_back (" --watch requires specifying a file" );
173
175
}
174
176
175
177
#ifndef ALLOW_ATTACHING_DEBUGGER_IN_WATCH_MODE
@@ -214,7 +216,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
214
216
heap_prof_dir = diagnostic_dir;
215
217
}
216
218
217
- debug_options_.CheckOptions (errors);
219
+ debug_options_.CheckOptions (errors, argv );
218
220
#endif // HAVE_INSPECTOR
219
221
}
220
222
0 commit comments