Skip to content

Commit 27ee802

Browse files
src: add watch config namespace
1 parent 6797c6e commit 27ee802

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

doc/api/cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ in the `$schema` must be replaced with the version of Node.js you are using.
10221022
},
10231023
"testRunner": {
10241024
"test-isolation": "process"
1025+
},
1026+
"watch": {
1027+
"watch-preserve-output": true
10251028
}
10261029
}
10271030
```

doc/node-config-schema.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,32 @@
734734
"type": "boolean"
735735
}
736736
}
737+
},
738+
"watch": {
739+
"type": "object",
740+
"additionalProperties": false,
741+
"properties": {
742+
"watch-kill-signal": {
743+
"type": "string"
744+
},
745+
"watch-path": {
746+
"oneOf": [
747+
{
748+
"type": "string"
749+
},
750+
{
751+
"items": {
752+
"type": "string",
753+
"minItems": 1
754+
},
755+
"type": "array"
756+
}
757+
]
758+
},
759+
"watch-preserve-output": {
760+
"type": "boolean"
761+
}
762+
}
737763
}
738764
},
739765
"type": "object"

src/node_options.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
242242
} else if (test_runner_force_exit) {
243243
errors->push_back("either --watch or --test-force-exit "
244244
"can be used, not both");
245-
} else if (!test_runner && (argv->size() < 1 || (*argv)[1].empty())) {
245+
} else if (!test_runner && watch_mode_paths.empty() &&
246+
(argv->size() < 1 || (*argv)[1].empty())) {
246247
errors->push_back("--watch requires specifying a file");
247248
}
248249

@@ -1017,16 +1018,20 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
10171018
AddOption("--watch-path",
10181019
"path to watch",
10191020
&EnvironmentOptions::watch_mode_paths,
1020-
kAllowedInEnvvar);
1021+
kAllowedInEnvvar,
1022+
OptionNamespaces::kWatchNamespace);
10211023
AddOption("--watch-kill-signal",
10221024
"kill signal to send to the process on watch mode restarts"
10231025
"(default: SIGTERM)",
10241026
&EnvironmentOptions::watch_mode_kill_signal,
1025-
kAllowedInEnvvar);
1027+
kAllowedInEnvvar,
1028+
OptionNamespaces::kWatchNamespace);
10261029
AddOption("--watch-preserve-output",
10271030
"preserve outputs on watch mode restart",
10281031
&EnvironmentOptions::watch_mode_preserve_output,
1029-
kAllowedInEnvvar);
1032+
kAllowedInEnvvar,
1033+
false,
1034+
OptionNamespaces::kWatchNamespace);
10301035
Implies("--watch-path", "--watch");
10311036
AddOption("--check",
10321037
"syntax check script without executing",

src/node_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ std::vector<std::string> MapAvailableNamespaces();
415415
// Define all namespace entries
416416
#define OPTION_NAMESPACE_LIST(V) \
417417
V(kNoNamespace, "") \
418-
V(kTestRunnerNamespace, "testRunner")
418+
V(kTestRunnerNamespace, "testRunner") \
419+
V(kWatchNamespace, "watch")
419420

420421
enum class OptionNamespaces {
421422
#define V(name, _) name,

0 commit comments

Comments
 (0)