mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
src: forbid running watch mode in REPL
PR-URL: https://github.com/nodejs/node/pull/45058 Fixes: https://github.com/nodejs/node/issues/45006 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
54eb543933
commit
c8264ad6ae
@ -331,7 +331,7 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
|
||||
return StartExecution(env, "internal/main/test_runner");
|
||||
}
|
||||
|
||||
if (env->options()->watch_mode && !first_argv.empty()) {
|
||||
if (env->options()->watch_mode) {
|
||||
return StartExecution(env, "internal/main/watch_mode");
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ void OptionsParser<Options>::Parse(
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
options->CheckOptions(errors);
|
||||
options->CheckOptions(errors, orig_args);
|
||||
}
|
||||
|
||||
} // namespace options_parser
|
||||
|
@ -34,7 +34,8 @@ Mutex cli_options_mutex;
|
||||
std::shared_ptr<PerProcessOptions> cli_options{new PerProcessOptions()};
|
||||
} // namespace per_process
|
||||
|
||||
void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
void DebugOptions::CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) {
|
||||
#if !NODE_USE_V8_PLATFORM && !HAVE_INSPECTOR
|
||||
if (inspector_enabled) {
|
||||
errors->push_back("Inspector is not available when Node is compiled "
|
||||
@ -64,7 +65,8 @@ void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
}
|
||||
}
|
||||
|
||||
void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
void PerProcessOptions::CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) {
|
||||
#if HAVE_OPENSSL
|
||||
if (use_openssl_ca && use_bundled_ca) {
|
||||
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) {
|
||||
use_largepages != "silent") {
|
||||
errors->push_back("invalid value for --use-largepages");
|
||||
}
|
||||
per_isolate->CheckOptions(errors);
|
||||
per_isolate->CheckOptions(errors, argv);
|
||||
}
|
||||
|
||||
void PerIsolateOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
per_env->CheckOptions(errors);
|
||||
void PerIsolateOptions::CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) {
|
||||
per_env->CheckOptions(errors, argv);
|
||||
}
|
||||
|
||||
void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) {
|
||||
if (has_policy_integrity_string && experimental_policy.empty()) {
|
||||
errors->push_back("--policy-integrity requires "
|
||||
"--experimental-policy be enabled");
|
||||
@ -161,15 +165,13 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
if (watch_mode) {
|
||||
if (syntax_check_only) {
|
||||
errors->push_back("either --watch or --check can be used, not both");
|
||||
}
|
||||
|
||||
if (has_eval_string) {
|
||||
} else if (has_eval_string) {
|
||||
errors->push_back("either --watch or --eval can be used, not both");
|
||||
}
|
||||
|
||||
if (force_repl) {
|
||||
} else if (force_repl) {
|
||||
errors->push_back("either --watch or --interactive "
|
||||
"can be used, not both");
|
||||
} else if (argv->size() < 1 || (*argv)[1].empty()) {
|
||||
errors->push_back("--watch requires specifying a file");
|
||||
}
|
||||
|
||||
#ifndef ALLOW_ATTACHING_DEBUGGER_IN_WATCH_MODE
|
||||
@ -214,7 +216,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
|
||||
heap_prof_dir = diagnostic_dir;
|
||||
}
|
||||
|
||||
debug_options_.CheckOptions(errors);
|
||||
debug_options_.CheckOptions(errors, argv);
|
||||
#endif // HAVE_INSPECTOR
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,8 @@ class HostPort {
|
||||
|
||||
class Options {
|
||||
public:
|
||||
virtual void CheckOptions(std::vector<std::string>* errors) {}
|
||||
virtual void CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) {}
|
||||
virtual ~Options() = default;
|
||||
};
|
||||
|
||||
@ -99,7 +100,8 @@ class DebugOptions : public Options {
|
||||
return break_first_line || break_node_first_line;
|
||||
}
|
||||
|
||||
void CheckOptions(std::vector<std::string>* errors) override;
|
||||
void CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) override;
|
||||
};
|
||||
|
||||
class EnvironmentOptions : public Options {
|
||||
@ -203,7 +205,8 @@ class EnvironmentOptions : public Options {
|
||||
inline DebugOptions* get_debug_options() { return &debug_options_; }
|
||||
inline const DebugOptions& debug_options() const { return debug_options_; }
|
||||
|
||||
void CheckOptions(std::vector<std::string>* errors) override;
|
||||
void CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) override;
|
||||
|
||||
private:
|
||||
DebugOptions debug_options_;
|
||||
@ -218,7 +221,8 @@ class PerIsolateOptions : public Options {
|
||||
bool experimental_shadow_realm = false;
|
||||
std::string report_signal = "SIGUSR2";
|
||||
inline EnvironmentOptions* get_per_env_options();
|
||||
void CheckOptions(std::vector<std::string>* errors) override;
|
||||
void CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) override;
|
||||
};
|
||||
|
||||
class PerProcessOptions : public Options {
|
||||
@ -291,7 +295,8 @@ class PerProcessOptions : public Options {
|
||||
std::vector<std::string> cmdline;
|
||||
|
||||
inline PerIsolateOptions* get_per_isolate_options();
|
||||
void CheckOptions(std::vector<std::string>* errors) override;
|
||||
void CheckOptions(std::vector<std::string>* errors,
|
||||
std::vector<std::string>* argv) override;
|
||||
};
|
||||
|
||||
// The actual options parser, as opposed to the structs containing them:
|
||||
|
Loading…
Reference in New Issue
Block a user