GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include "node_options.h" // NOLINT(build/include_inline) |
||
2 |
#include "node_options-inl.h" |
||
3 |
|||
4 |
#include "env-inl.h" |
||
5 |
#include "node_binding.h" |
||
6 |
|||
7 |
#include <cstdlib> // strtoul, errno |
||
8 |
|||
9 |
using v8::Boolean; |
||
10 |
using v8::Context; |
||
11 |
using v8::FunctionCallbackInfo; |
||
12 |
using v8::Integer; |
||
13 |
using v8::Isolate; |
||
14 |
using v8::Local; |
||
15 |
using v8::Map; |
||
16 |
using v8::Number; |
||
17 |
using v8::Object; |
||
18 |
using v8::String; |
||
19 |
using v8::Undefined; |
||
20 |
using v8::Value; |
||
21 |
|||
22 |
namespace node { |
||
23 |
|||
24 |
namespace per_process { |
||
25 |
4944 |
Mutex cli_options_mutex; |
|
26 |
4944 |
std::shared_ptr<PerProcessOptions> cli_options{new PerProcessOptions()}; |
|
27 |
} // namespace per_process |
||
28 |
|||
29 |
9729 |
void DebugOptions::CheckOptions(std::vector<std::string>* errors) { |
|
30 |
#if !NODE_USE_V8_PLATFORM |
||
31 |
if (inspector_enabled) { |
||
32 |
errors->push_back("Inspector is not available when Node is compiled " |
||
33 |
"--without-v8-platform"); |
||
34 |
} |
||
35 |
#endif |
||
36 |
|||
37 |
✓✓ | 9729 |
if (deprecated_debug) { |
38 |
errors->push_back("[DEP0062]: `node --debug` and `node --debug-brk` " |
||
39 |
"are invalid. Please use `node --inspect` and " |
||
40 |
5 |
"`node --inspect-brk` instead."); |
|
41 |
} |
||
42 |
|||
43 |
std::vector<std::string> destinations = |
||
44 |
9729 |
SplitString(inspect_publish_uid_string, ','); |
|
45 |
9729 |
inspect_publish_uid.console = false; |
|
46 |
9729 |
inspect_publish_uid.http = false; |
|
47 |
✓✓ | 29185 |
for (const std::string& destination : destinations) { |
48 |
✓✓ | 19456 |
if (destination == "stderr") { |
49 |
9728 |
inspect_publish_uid.console = true; |
|
50 |
✓✗ | 9728 |
} else if (destination == "http") { |
51 |
9728 |
inspect_publish_uid.http = true; |
|
52 |
} else { |
||
53 |
errors->push_back("--inspect-publish-uid destination can be " |
||
54 |
"stderr or http"); |
||
55 |
} |
||
56 |
9729 |
} |
|
57 |
9729 |
} |
|
58 |
|||
59 |
9717 |
void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) { |
|
60 |
#if HAVE_OPENSSL |
||
61 |
✓✓✓✓ |
9717 |
if (use_openssl_ca && use_bundled_ca) { |
62 |
errors->push_back("either --use-openssl-ca or --use-bundled-ca can be " |
||
63 |
1 |
"used, not both"); |
|
64 |
} |
||
65 |
#endif |
||
66 |
9717 |
per_isolate->CheckOptions(errors); |
|
67 |
9717 |
} |
|
68 |
|||
69 |
9729 |
void PerIsolateOptions::CheckOptions(std::vector<std::string>* errors) { |
|
70 |
9729 |
per_env->CheckOptions(errors); |
|
71 |
#ifdef NODE_REPORT |
||
72 |
✓✓ | 9729 |
if (per_env->experimental_report) { |
73 |
// Assign the report_signal default value here. Once the |
||
74 |
// --experimental-report flag is dropped, move this initialization to |
||
75 |
// node_options.h, where report_signal is declared. |
||
76 |
✓✗ | 10 |
if (report_signal.empty()) |
77 |
10 |
report_signal = "SIGUSR2"; |
|
78 |
9739 |
return; |
|
79 |
} |
||
80 |
|||
81 |
✗✓ | 9719 |
if (!report_directory.empty()) { |
82 |
errors->push_back("--report-directory option is valid only when " |
||
83 |
"--experimental-report is set"); |
||
84 |
} |
||
85 |
|||
86 |
✗✓ | 9719 |
if (!report_filename.empty()) { |
87 |
errors->push_back("--report-filename option is valid only when " |
||
88 |
"--experimental-report is set"); |
||
89 |
} |
||
90 |
|||
91 |
✗✓ | 9719 |
if (!report_signal.empty()) { |
92 |
errors->push_back("--report-signal option is valid only when " |
||
93 |
"--experimental-report is set"); |
||
94 |
} |
||
95 |
|||
96 |
✗✓ | 9719 |
if (report_on_fatalerror) { |
97 |
errors->push_back( |
||
98 |
"--report-on-fatalerror option is valid only when " |
||
99 |
"--experimental-report is set"); |
||
100 |
} |
||
101 |
|||
102 |
✗✓ | 9719 |
if (report_on_signal) { |
103 |
errors->push_back("--report-on-signal option is valid only when " |
||
104 |
"--experimental-report is set"); |
||
105 |
} |
||
106 |
|||
107 |
✗✓ | 9719 |
if (report_uncaught_exception) { |
108 |
errors->push_back( |
||
109 |
"--report-uncaught-exception option is valid only when " |
||
110 |
"--experimental-report is set"); |
||
111 |
} |
||
112 |
#endif // NODE_REPORT |
||
113 |
} |
||
114 |
|||
115 |
9729 |
void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) { |
|
116 |
✓✓✗✓ ✗✓ |
9729 |
if (!userland_loader.empty() && !experimental_modules) { |
117 |
errors->push_back("--experimental-loader requires " |
||
118 |
"--experimental-modules be enabled"); |
||
119 |
} |
||
120 |
✓✓✗✓ ✗✓ |
9729 |
if (has_policy_integrity_string && experimental_policy.empty()) { |
121 |
errors->push_back("--policy-integrity requires " |
||
122 |
"--experimental-policy be enabled"); |
||
123 |
} |
||
124 |
✓✓✓✓ ✓✓ |
9729 |
if (has_policy_integrity_string && experimental_policy_integrity.empty()) { |
125 |
1 |
errors->push_back("--policy-integrity cannot be empty"); |
|
126 |
} |
||
127 |
|||
128 |
✓✓ | 9729 |
if (!module_type.empty()) { |
129 |
✗✓ | 13 |
if (!experimental_modules) { |
130 |
errors->push_back("--input-type requires " |
||
131 |
"--experimental-modules to be enabled"); |
||
132 |
} |
||
133 |
✓✗✗✓ ✗✓ |
13 |
if (module_type != "commonjs" && module_type != "module") { |
134 |
errors->push_back("--input-type must be \"module\" or \"commonjs\""); |
||
135 |
} |
||
136 |
} |
||
137 |
|||
138 |
✓✓✗✓ |
9729 |
if (experimental_wasm_modules && !experimental_modules) { |
139 |
errors->push_back("--experimental-wasm-modules requires " |
||
140 |
"--experimental-modules be enabled"); |
||
141 |
} |
||
142 |
|||
143 |
✓✓ | 9729 |
if (!es_module_specifier_resolution.empty()) { |
144 |
✗✓ | 1 |
if (!experimental_modules) { |
145 |
errors->push_back("--es-module-specifier-resolution requires " |
||
146 |
"--experimental-modules be enabled"); |
||
147 |
} |
||
148 |
✗✓✗✗ ✗✓ |
1 |
if (es_module_specifier_resolution != "node" && |
149 |
es_module_specifier_resolution != "explicit") { |
||
150 |
errors->push_back("invalid value for --es-module-specifier-resolution"); |
||
151 |
} |
||
152 |
} |
||
153 |
|||
154 |
✓✓✓✓ |
9729 |
if (syntax_check_only && has_eval_string) { |
155 |
4 |
errors->push_back("either --check or --eval can be used, not both"); |
|
156 |
} |
||
157 |
|||
158 |
✓✓✓✓ |
19467 |
if (!unhandled_rejections.empty() && |
159 |
✓✓ | 16 |
unhandled_rejections != "strict" && |
160 |
✓✓✓✓ |
9741 |
unhandled_rejections != "warn" && |
161 |
5 |
unhandled_rejections != "none") { |
|
162 |
1 |
errors->push_back("invalid value for --unhandled-rejections"); |
|
163 |
} |
||
164 |
|||
165 |
✓✓✓✓ |
9729 |
if (tls_min_v1_3 && tls_max_v1_2) { |
166 |
errors->push_back("either --tls-min-v1.3 or --tls-max-v1.2 can be " |
||
167 |
1 |
"used, not both"); |
|
168 |
} |
||
169 |
|||
170 |
#if HAVE_INSPECTOR |
||
171 |
✓✓ | 9729 |
if (!cpu_prof) { |
172 |
✓✓ | 9720 |
if (!cpu_prof_name.empty()) { |
173 |
1 |
errors->push_back("--cpu-prof-name must be used with --cpu-prof"); |
|
174 |
} |
||
175 |
✗✓ | 9720 |
if (!cpu_prof_dir.empty()) { |
176 |
errors->push_back("--cpu-prof-dir must be used with --cpu-prof"); |
||
177 |
} |
||
178 |
// We can't catch the case where the value passed is the default value, |
||
179 |
// then the option just becomes a noop which is fine. |
||
180 |
✗✓ | 9720 |
if (cpu_prof_interval != kDefaultCpuProfInterval) { |
181 |
errors->push_back("--cpu-prof-interval must be used with --cpu-prof"); |
||
182 |
} |
||
183 |
} |
||
184 |
|||
185 |
✓✓ | 9729 |
if (!heap_prof) { |
186 |
✓✓ | 9725 |
if (!heap_prof_name.empty()) { |
187 |
1 |
errors->push_back("--heap-prof-name must be used with --heap-prof"); |
|
188 |
} |
||
189 |
✗✓ | 9725 |
if (!heap_prof_dir.empty()) { |
190 |
errors->push_back("--heap-prof-dir must be used with --heap-prof"); |
||
191 |
} |
||
192 |
// We can't catch the case where the value passed is the default value, |
||
193 |
// then the option just becomes a noop which is fine. |
||
194 |
✗✓ | 9725 |
if (heap_prof_interval != kDefaultHeapProfInterval) { |
195 |
errors->push_back("--heap-prof-interval must be used with --heap-prof"); |
||
196 |
} |
||
197 |
} |
||
198 |
9729 |
debug_options_.CheckOptions(errors); |
|
199 |
#endif // HAVE_INSPECTOR |
||
200 |
9729 |
} |
|
201 |
|||
202 |
namespace options_parser { |
||
203 |
|||
204 |
✗✓ | 4944 |
class DebugOptionsParser : public OptionsParser<DebugOptions> { |
205 |
public: |
||
206 |
DebugOptionsParser(); |
||
207 |
}; |
||
208 |
|||
209 |
✗✓ | 4944 |
class EnvironmentOptionsParser : public OptionsParser<EnvironmentOptions> { |
210 |
public: |
||
211 |
EnvironmentOptionsParser(); |
||
212 |
4944 |
explicit EnvironmentOptionsParser(const DebugOptionsParser& dop) |
|
213 |
4944 |
: EnvironmentOptionsParser() { |
|
214 |
4944 |
Insert(dop, &EnvironmentOptions::get_debug_options); |
|
215 |
4944 |
} |
|
216 |
}; |
||
217 |
|||
218 |
✗✓ | 4944 |
class PerIsolateOptionsParser : public OptionsParser<PerIsolateOptions> { |
219 |
public: |
||
220 |
PerIsolateOptionsParser() = delete; |
||
221 |
explicit PerIsolateOptionsParser(const EnvironmentOptionsParser& eop); |
||
222 |
}; |
||
223 |
|||
224 |
✗✓ | 4944 |
class PerProcessOptionsParser : public OptionsParser<PerProcessOptions> { |
225 |
public: |
||
226 |
PerProcessOptionsParser() = delete; |
||
227 |
explicit PerProcessOptionsParser(const PerIsolateOptionsParser& iop); |
||
228 |
}; |
||
229 |
|||
230 |
#if HAVE_INSPECTOR |
||
231 |
4944 |
const DebugOptionsParser _dop_instance{}; |
|
232 |
4944 |
const EnvironmentOptionsParser _eop_instance{_dop_instance}; |
|
233 |
|||
234 |
// This Parse is not dead code. It is used by embedders (e.g., Electron). |
||
235 |
template <> |
||
236 |
void Parse( |
||
237 |
StringVector* const args, StringVector* const exec_args, |
||
238 |
StringVector* const v8_args, |
||
239 |
DebugOptions* const options, |
||
240 |
OptionEnvvarSettings required_env_settings, StringVector* const errors) { |
||
241 |
_dop_instance.Parse( |
||
242 |
args, exec_args, v8_args, options, required_env_settings, errors); |
||
243 |
} |
||
244 |
#else |
||
245 |
const EnvironmentOptionsParser _eop_instance{}; |
||
246 |
#endif // HAVE_INSPECTOR |
||
247 |
4944 |
const PerIsolateOptionsParser _piop_instance{_eop_instance}; |
|
248 |
4944 |
const PerProcessOptionsParser _ppop_instance{_piop_instance}; |
|
249 |
|||
250 |
template <> |
||
251 |
12 |
void Parse( |
|
252 |
StringVector* const args, StringVector* const exec_args, |
||
253 |
StringVector* const v8_args, |
||
254 |
PerIsolateOptions* const options, |
||
255 |
OptionEnvvarSettings required_env_settings, StringVector* const errors) { |
||
256 |
_piop_instance.Parse( |
||
257 |
12 |
args, exec_args, v8_args, options, required_env_settings, errors); |
|
258 |
12 |
} |
|
259 |
|||
260 |
template <> |
||
261 |
9717 |
void Parse( |
|
262 |
StringVector* const args, StringVector* const exec_args, |
||
263 |
StringVector* const v8_args, |
||
264 |
PerProcessOptions* const options, |
||
265 |
OptionEnvvarSettings required_env_settings, StringVector* const errors) { |
||
266 |
_ppop_instance.Parse( |
||
267 |
9717 |
args, exec_args, v8_args, options, required_env_settings, errors); |
|
268 |
9717 |
} |
|
269 |
|||
270 |
// XXX: If you add an option here, please also add it to doc/node.1 and |
||
271 |
// doc/api/cli.md |
||
272 |
// TODO(addaleax): Make that unnecessary. |
||
273 |
|||
274 |
4944 |
DebugOptionsParser::DebugOptionsParser() { |
|
275 |
AddOption("--inspect-port", |
||
276 |
"set host:port for inspector", |
||
277 |
&DebugOptions::host_port, |
||
278 |
4944 |
kAllowedInEnvironment); |
|
279 |
4944 |
AddAlias("--debug-port", "--inspect-port"); |
|
280 |
|||
281 |
AddOption("--inspect", |
||
282 |
"activate inspector on host:port (default: 127.0.0.1:9229)", |
||
283 |
&DebugOptions::inspector_enabled, |
||
284 |
4944 |
kAllowedInEnvironment); |
|
285 |
✓✓ | 4944 |
AddAlias("--inspect=", { "--inspect-port", "--inspect" }); |
286 |
|||
287 |
4944 |
AddOption("--debug", "", &DebugOptions::deprecated_debug); |
|
288 |
4944 |
AddAlias("--debug=", "--debug"); |
|
289 |
4944 |
AddOption("--debug-brk", "", &DebugOptions::deprecated_debug); |
|
290 |
4944 |
AddAlias("--debug-brk=", "--debug-brk"); |
|
291 |
|||
292 |
AddOption("--inspect-brk", |
||
293 |
"activate inspector on host:port and break at start of user script", |
||
294 |
&DebugOptions::break_first_line, |
||
295 |
4944 |
kAllowedInEnvironment); |
|
296 |
4944 |
Implies("--inspect-brk", "--inspect"); |
|
297 |
✓✓ | 4944 |
AddAlias("--inspect-brk=", { "--inspect-port", "--inspect-brk" }); |
298 |
|||
299 |
4944 |
AddOption("--inspect-brk-node", "", &DebugOptions::break_node_first_line); |
|
300 |
4944 |
Implies("--inspect-brk-node", "--inspect"); |
|
301 |
✓✓ | 4944 |
AddAlias("--inspect-brk-node=", { "--inspect-port", "--inspect-brk-node" }); |
302 |
|||
303 |
AddOption("--inspect-publish-uid", |
||
304 |
"comma separated list of destinations for inspector uid" |
||
305 |
"(default: stderr,http)", |
||
306 |
&DebugOptions::inspect_publish_uid_string, |
||
307 |
4944 |
kAllowedInEnvironment); |
|
308 |
4944 |
} |
|
309 |
|||
310 |
4944 |
EnvironmentOptionsParser::EnvironmentOptionsParser() { |
|
311 |
AddOption("--enable-source-maps", |
||
312 |
"experimental Source Map V3 support", |
||
313 |
&EnvironmentOptions::enable_source_maps, |
||
314 |
4944 |
kAllowedInEnvironment); |
|
315 |
AddOption("--experimental-exports", |
||
316 |
"experimental support for exports in package.json", |
||
317 |
&EnvironmentOptions::experimental_exports, |
||
318 |
4944 |
kAllowedInEnvironment); |
|
319 |
AddOption("--experimental-loader", |
||
320 |
"(with --experimental-modules) use the specified file as a " |
||
321 |
"custom loader", |
||
322 |
&EnvironmentOptions::userland_loader, |
||
323 |
4944 |
kAllowedInEnvironment); |
|
324 |
4944 |
AddAlias("--loader", "--experimental-loader"); |
|
325 |
AddOption("--experimental-modules", |
||
326 |
"experimental ES Module support and caching modules", |
||
327 |
&EnvironmentOptions::experimental_modules, |
||
328 |
4944 |
kAllowedInEnvironment); |
|
329 |
4944 |
Implies("--experimental-modules", "--experimental-exports"); |
|
330 |
AddOption("--experimental-wasm-modules", |
||
331 |
"experimental ES Module support for webassembly modules", |
||
332 |
&EnvironmentOptions::experimental_wasm_modules, |
||
333 |
4944 |
kAllowedInEnvironment); |
|
334 |
AddOption("--experimental-policy", |
||
335 |
"use the specified file as a " |
||
336 |
"security policy", |
||
337 |
&EnvironmentOptions::experimental_policy, |
||
338 |
4944 |
kAllowedInEnvironment); |
|
339 |
AddOption("[has_policy_integrity_string]", |
||
340 |
"", |
||
341 |
4944 |
&EnvironmentOptions::has_policy_integrity_string); |
|
342 |
AddOption("--policy-integrity", |
||
343 |
"ensure the security policy contents match " |
||
344 |
"the specified integrity", |
||
345 |
&EnvironmentOptions::experimental_policy_integrity, |
||
346 |
4944 |
kAllowedInEnvironment); |
|
347 |
4944 |
Implies("--policy-integrity", "[has_policy_integrity_string]"); |
|
348 |
AddOption("--experimental-repl-await", |
||
349 |
"experimental await keyword support in REPL", |
||
350 |
&EnvironmentOptions::experimental_repl_await, |
||
351 |
4944 |
kAllowedInEnvironment); |
|
352 |
AddOption("--experimental-vm-modules", |
||
353 |
"experimental ES Module support in vm module", |
||
354 |
&EnvironmentOptions::experimental_vm_modules, |
||
355 |
4944 |
kAllowedInEnvironment); |
|
356 |
4944 |
AddOption("--experimental-worker", "", NoOp{}, kAllowedInEnvironment); |
|
357 |
#ifdef NODE_REPORT |
||
358 |
AddOption("--experimental-report", |
||
359 |
"enable report generation", |
||
360 |
&EnvironmentOptions::experimental_report, |
||
361 |
4944 |
kAllowedInEnvironment); |
|
362 |
#endif // NODE_REPORT |
||
363 |
4944 |
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals); |
|
364 |
AddOption("--frozen-intrinsics", |
||
365 |
"experimental frozen intrinsics support", |
||
366 |
&EnvironmentOptions::frozen_intrinsics, |
||
367 |
4944 |
kAllowedInEnvironment); |
|
368 |
AddOption("--heapsnapshot-signal", |
||
369 |
"Generate heap snapshot on specified signal", |
||
370 |
&EnvironmentOptions::heap_snapshot_signal, |
||
371 |
4944 |
kAllowedInEnvironment); |
|
372 |
4944 |
AddOption("--http-parser", "", NoOp{}, kAllowedInEnvironment); |
|
373 |
AddOption("--input-type", |
||
374 |
"set module type for string input", |
||
375 |
&EnvironmentOptions::module_type, |
||
376 |
4944 |
kAllowedInEnvironment); |
|
377 |
AddOption("--es-module-specifier-resolution", |
||
378 |
"Select extension resolution algorithm for es modules; " |
||
379 |
"either 'explicit' (default) or 'node'", |
||
380 |
&EnvironmentOptions::es_module_specifier_resolution, |
||
381 |
4944 |
kAllowedInEnvironment); |
|
382 |
AddOption("--no-deprecation", |
||
383 |
"silence deprecation warnings", |
||
384 |
&EnvironmentOptions::no_deprecation, |
||
385 |
4944 |
kAllowedInEnvironment); |
|
386 |
AddOption("--no-force-async-hooks-checks", |
||
387 |
"disable checks for async_hooks", |
||
388 |
&EnvironmentOptions::no_force_async_hooks_checks, |
||
389 |
4944 |
kAllowedInEnvironment); |
|
390 |
AddOption("--no-warnings", |
||
391 |
"silence all process warnings", |
||
392 |
&EnvironmentOptions::no_warnings, |
||
393 |
4944 |
kAllowedInEnvironment); |
|
394 |
AddOption("--force-context-aware", |
||
395 |
"disable loading non-context-aware addons", |
||
396 |
&EnvironmentOptions::force_context_aware, |
||
397 |
4944 |
kAllowedInEnvironment); |
|
398 |
AddOption("--pending-deprecation", |
||
399 |
"emit pending deprecation warnings", |
||
400 |
&EnvironmentOptions::pending_deprecation, |
||
401 |
4944 |
kAllowedInEnvironment); |
|
402 |
AddOption("--preserve-symlinks", |
||
403 |
"preserve symbolic links when resolving", |
||
404 |
&EnvironmentOptions::preserve_symlinks, |
||
405 |
4944 |
kAllowedInEnvironment); |
|
406 |
AddOption("--preserve-symlinks-main", |
||
407 |
"preserve symbolic links when resolving the main module", |
||
408 |
&EnvironmentOptions::preserve_symlinks_main, |
||
409 |
4944 |
kAllowedInEnvironment); |
|
410 |
AddOption("--prof-process", |
||
411 |
"process V8 profiler output generated using --prof", |
||
412 |
4944 |
&EnvironmentOptions::prof_process); |
|
413 |
// Options after --prof-process are passed through to the prof processor. |
||
414 |
✓✓ | 4944 |
AddAlias("--prof-process", { "--prof-process", "--" }); |
415 |
#if HAVE_INSPECTOR |
||
416 |
AddOption("--cpu-prof", |
||
417 |
"Start the V8 CPU profiler on start up, and write the CPU profile " |
||
418 |
"to disk before exit. If --cpu-prof-dir is not specified, write " |
||
419 |
"the profile to the current working directory.", |
||
420 |
4944 |
&EnvironmentOptions::cpu_prof); |
|
421 |
AddOption("--cpu-prof-name", |
||
422 |
"specified file name of the V8 CPU profile generated with " |
||
423 |
"--cpu-prof", |
||
424 |
4944 |
&EnvironmentOptions::cpu_prof_name); |
|
425 |
AddOption("--cpu-prof-interval", |
||
426 |
"specified sampling interval in microseconds for the V8 CPU " |
||
427 |
"profile generated with --cpu-prof. (default: 1000)", |
||
428 |
4944 |
&EnvironmentOptions::cpu_prof_interval); |
|
429 |
AddOption("--cpu-prof-dir", |
||
430 |
"Directory where the V8 profiles generated by --cpu-prof will be " |
||
431 |
"placed. Does not affect --prof.", |
||
432 |
4944 |
&EnvironmentOptions::cpu_prof_dir); |
|
433 |
AddOption( |
||
434 |
"--heap-prof", |
||
435 |
"Start the V8 heap profiler on start up, and write the heap profile " |
||
436 |
"to disk before exit. If --heap-prof-dir is not specified, write " |
||
437 |
"the profile to the current working directory.", |
||
438 |
4944 |
&EnvironmentOptions::heap_prof); |
|
439 |
AddOption("--heap-prof-name", |
||
440 |
"specified file name of the V8 CPU profile generated with " |
||
441 |
"--heap-prof", |
||
442 |
4944 |
&EnvironmentOptions::heap_prof_name); |
|
443 |
AddOption("--heap-prof-dir", |
||
444 |
"Directory where the V8 heap profiles generated by --heap-prof " |
||
445 |
"will be placed.", |
||
446 |
4944 |
&EnvironmentOptions::heap_prof_dir); |
|
447 |
AddOption("--heap-prof-interval", |
||
448 |
"specified sampling interval in bytes for the V8 heap " |
||
449 |
"profile generated with --heap-prof. (default: 512 * 1024)", |
||
450 |
4944 |
&EnvironmentOptions::heap_prof_interval); |
|
451 |
#endif // HAVE_INSPECTOR |
||
452 |
AddOption("--redirect-warnings", |
||
453 |
"write warnings to file instead of stderr", |
||
454 |
&EnvironmentOptions::redirect_warnings, |
||
455 |
4944 |
kAllowedInEnvironment); |
|
456 |
AddOption("--test-udp-no-try-send", "", // For testing only. |
||
457 |
4944 |
&EnvironmentOptions::test_udp_no_try_send); |
|
458 |
AddOption("--throw-deprecation", |
||
459 |
"throw an exception on deprecations", |
||
460 |
&EnvironmentOptions::throw_deprecation, |
||
461 |
4944 |
kAllowedInEnvironment); |
|
462 |
AddOption("--trace-deprecation", |
||
463 |
"show stack traces on deprecations", |
||
464 |
&EnvironmentOptions::trace_deprecation, |
||
465 |
4944 |
kAllowedInEnvironment); |
|
466 |
AddOption("--trace-sync-io", |
||
467 |
"show stack trace when use of sync IO is detected after the " |
||
468 |
"first tick", |
||
469 |
&EnvironmentOptions::trace_sync_io, |
||
470 |
4944 |
kAllowedInEnvironment); |
|
471 |
AddOption("--trace-tls", |
||
472 |
"prints TLS packet trace information to stderr", |
||
473 |
&EnvironmentOptions::trace_tls, |
||
474 |
4944 |
kAllowedInEnvironment); |
|
475 |
AddOption("--trace-warnings", |
||
476 |
"show stack traces on process warnings", |
||
477 |
&EnvironmentOptions::trace_warnings, |
||
478 |
4944 |
kAllowedInEnvironment); |
|
479 |
AddOption("--unhandled-rejections", |
||
480 |
"define unhandled rejections behavior. Options are 'strict' (raise " |
||
481 |
"an error), 'warn' (enforce warnings) or 'none' (silence warnings)", |
||
482 |
&EnvironmentOptions::unhandled_rejections, |
||
483 |
4944 |
kAllowedInEnvironment); |
|
484 |
|||
485 |
AddOption("--check", |
||
486 |
"syntax check script without executing", |
||
487 |
4944 |
&EnvironmentOptions::syntax_check_only); |
|
488 |
4944 |
AddAlias("-c", "--check"); |
|
489 |
// This option is only so that we can tell --eval with an empty string from |
||
490 |
// no eval at all. Having it not start with a dash makes it inaccessible |
||
491 |
// from the parser itself, but available for using Implies(). |
||
492 |
// TODO(addaleax): When moving --help over to something generated from the |
||
493 |
// programmatic descriptions, this will need some special care. |
||
494 |
// (See also [ssl_openssl_cert_store] below.) |
||
495 |
4944 |
AddOption("[has_eval_string]", "", &EnvironmentOptions::has_eval_string); |
|
496 |
4944 |
AddOption("--eval", "evaluate script", &EnvironmentOptions::eval_string); |
|
497 |
4944 |
Implies("--eval", "[has_eval_string]"); |
|
498 |
AddOption("--print", |
||
499 |
"evaluate script and print result", |
||
500 |
4944 |
&EnvironmentOptions::print_eval); |
|
501 |
4944 |
AddAlias("-e", "--eval"); |
|
502 |
4944 |
AddAlias("--print <arg>", "-pe"); |
|
503 |
✓✓ | 4944 |
AddAlias("-pe", { "--print", "--eval" }); |
504 |
4944 |
AddAlias("-p", "--print"); |
|
505 |
AddOption("--require", |
||
506 |
"module to preload (option can be repeated)", |
||
507 |
&EnvironmentOptions::preload_modules, |
||
508 |
4944 |
kAllowedInEnvironment); |
|
509 |
4944 |
AddAlias("-r", "--require"); |
|
510 |
AddOption("--interactive", |
||
511 |
"always enter the REPL even if stdin does not appear " |
||
512 |
"to be a terminal", |
||
513 |
4944 |
&EnvironmentOptions::force_repl); |
|
514 |
4944 |
AddAlias("-i", "--interactive"); |
|
515 |
|||
516 |
4944 |
AddOption("--napi-modules", "", NoOp{}, kAllowedInEnvironment); |
|
517 |
|||
518 |
AddOption("--tls-min-v1.0", |
||
519 |
"set default TLS minimum to TLSv1.0 (default: TLSv1.2)", |
||
520 |
&EnvironmentOptions::tls_min_v1_0, |
||
521 |
4944 |
kAllowedInEnvironment); |
|
522 |
AddOption("--tls-min-v1.1", |
||
523 |
"set default TLS minimum to TLSv1.1 (default: TLSv1.2)", |
||
524 |
&EnvironmentOptions::tls_min_v1_1, |
||
525 |
4944 |
kAllowedInEnvironment); |
|
526 |
AddOption("--tls-min-v1.2", |
||
527 |
"set default TLS minimum to TLSv1.2 (default: TLSv1.2)", |
||
528 |
&EnvironmentOptions::tls_min_v1_2, |
||
529 |
4944 |
kAllowedInEnvironment); |
|
530 |
AddOption("--tls-min-v1.3", |
||
531 |
"set default TLS minimum to TLSv1.3 (default: TLSv1.2)", |
||
532 |
&EnvironmentOptions::tls_min_v1_3, |
||
533 |
4944 |
kAllowedInEnvironment); |
|
534 |
AddOption("--tls-max-v1.2", |
||
535 |
"set default TLS maximum to TLSv1.2 (default: TLSv1.3)", |
||
536 |
&EnvironmentOptions::tls_max_v1_2, |
||
537 |
4944 |
kAllowedInEnvironment); |
|
538 |
// Current plan is: |
||
539 |
// - 11.x and below: TLS1.3 is opt-in with --tls-max-v1.3 |
||
540 |
// - 12.x: TLS1.3 is opt-out with --tls-max-v1.2 |
||
541 |
// In either case, support both options they are uniformly available. |
||
542 |
AddOption("--tls-max-v1.3", |
||
543 |
"set default TLS maximum to TLSv1.3 (default: TLSv1.3)", |
||
544 |
&EnvironmentOptions::tls_max_v1_3, |
||
545 |
4944 |
kAllowedInEnvironment); |
|
546 |
4944 |
} |
|
547 |
|||
548 |
4944 |
PerIsolateOptionsParser::PerIsolateOptionsParser( |
|
549 |
4944 |
const EnvironmentOptionsParser& eop) { |
|
550 |
AddOption("--track-heap-objects", |
||
551 |
"track heap object allocations for heap snapshots", |
||
552 |
&PerIsolateOptions::track_heap_objects, |
||
553 |
4944 |
kAllowedInEnvironment); |
|
554 |
AddOption("--no-node-snapshot", |
||
555 |
"", // It's a debug-only option. |
||
556 |
&PerIsolateOptions::no_node_snapshot, |
||
557 |
4944 |
kAllowedInEnvironment); |
|
558 |
|||
559 |
// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS. |
||
560 |
AddOption("--abort-on-uncaught-exception", |
||
561 |
"aborting instead of exiting causes a core file to be generated " |
||
562 |
"for analysis", |
||
563 |
V8Option{}, |
||
564 |
4944 |
kAllowedInEnvironment); |
|
565 |
AddOption("--interpreted-frames-native-stack", |
||
566 |
"help system profilers to translate JavaScript interpreted frames", |
||
567 |
4944 |
V8Option{}, kAllowedInEnvironment); |
|
568 |
4944 |
AddOption("--max-old-space-size", "", V8Option{}, kAllowedInEnvironment); |
|
569 |
4944 |
AddOption("--perf-basic-prof", "", V8Option{}, kAllowedInEnvironment); |
|
570 |
AddOption("--perf-basic-prof-only-functions", |
||
571 |
"", |
||
572 |
V8Option{}, |
||
573 |
4944 |
kAllowedInEnvironment); |
|
574 |
4944 |
AddOption("--perf-prof", "", V8Option{}, kAllowedInEnvironment); |
|
575 |
AddOption("--perf-prof-unwinding-info", |
||
576 |
"", |
||
577 |
V8Option{}, |
||
578 |
4944 |
kAllowedInEnvironment); |
|
579 |
4944 |
AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment); |
|
580 |
|||
581 |
#ifdef NODE_REPORT |
||
582 |
AddOption("--report-uncaught-exception", |
||
583 |
"generate diagnostic report on uncaught exceptions", |
||
584 |
&PerIsolateOptions::report_uncaught_exception, |
||
585 |
4944 |
kAllowedInEnvironment); |
|
586 |
AddOption("--report-on-signal", |
||
587 |
"generate diagnostic report upon receiving signals", |
||
588 |
&PerIsolateOptions::report_on_signal, |
||
589 |
4944 |
kAllowedInEnvironment); |
|
590 |
AddOption("--report-on-fatalerror", |
||
591 |
"generate diagnostic report on fatal (internal) errors", |
||
592 |
&PerIsolateOptions::report_on_fatalerror, |
||
593 |
4944 |
kAllowedInEnvironment); |
|
594 |
AddOption("--report-signal", |
||
595 |
"causes diagnostic report to be produced on provided signal," |
||
596 |
" unsupported in Windows. (default: SIGUSR2)", |
||
597 |
&PerIsolateOptions::report_signal, |
||
598 |
4944 |
kAllowedInEnvironment); |
|
599 |
4944 |
Implies("--report-signal", "--report-on-signal"); |
|
600 |
AddOption("--report-filename", |
||
601 |
"define custom report file name." |
||
602 |
" (default: YYYYMMDD.HHMMSS.PID.SEQUENCE#.txt)", |
||
603 |
&PerIsolateOptions::report_filename, |
||
604 |
4944 |
kAllowedInEnvironment); |
|
605 |
AddOption("--report-directory", |
||
606 |
"define custom report pathname." |
||
607 |
" (default: current working directory of Node.js process)", |
||
608 |
&PerIsolateOptions::report_directory, |
||
609 |
4944 |
kAllowedInEnvironment); |
|
610 |
#endif // NODE_REPORT |
||
611 |
|||
612 |
4944 |
Insert(eop, &PerIsolateOptions::get_per_env_options); |
|
613 |
4944 |
} |
|
614 |
|||
615 |
4944 |
PerProcessOptionsParser::PerProcessOptionsParser( |
|
616 |
4944 |
const PerIsolateOptionsParser& iop) { |
|
617 |
AddOption("--title", |
||
618 |
"the process title to use on startup", |
||
619 |
&PerProcessOptions::title, |
||
620 |
4944 |
kAllowedInEnvironment); |
|
621 |
AddOption("--trace-event-categories", |
||
622 |
"comma separated list of trace event categories to record", |
||
623 |
&PerProcessOptions::trace_event_categories, |
||
624 |
4944 |
kAllowedInEnvironment); |
|
625 |
AddOption("--trace-event-file-pattern", |
||
626 |
"Template string specifying the filepath for the trace-events " |
||
627 |
"data, it supports ${rotation} and ${pid}.", |
||
628 |
&PerProcessOptions::trace_event_file_pattern, |
||
629 |
4944 |
kAllowedInEnvironment); |
|
630 |
AddAlias("--trace-events-enabled", { |
||
631 |
✓✓ | 4944 |
"--trace-event-categories", "v8,node,node.async_hooks" }); |
632 |
AddOption("--max-http-header-size", |
||
633 |
"set the maximum size of HTTP headers (default: 8KB)", |
||
634 |
&PerProcessOptions::max_http_header_size, |
||
635 |
4944 |
kAllowedInEnvironment); |
|
636 |
AddOption("--v8-pool-size", |
||
637 |
"set V8's thread pool size", |
||
638 |
&PerProcessOptions::v8_thread_pool_size, |
||
639 |
4944 |
kAllowedInEnvironment); |
|
640 |
AddOption("--zero-fill-buffers", |
||
641 |
"automatically zero-fill all newly allocated Buffer and " |
||
642 |
"SlowBuffer instances", |
||
643 |
&PerProcessOptions::zero_fill_all_buffers, |
||
644 |
4944 |
kAllowedInEnvironment); |
|
645 |
AddOption("--debug-arraybuffer-allocations", |
||
646 |
"", /* undocumented, only for debugging */ |
||
647 |
&PerProcessOptions::debug_arraybuffer_allocations, |
||
648 |
4944 |
kAllowedInEnvironment); |
|
649 |
|||
650 |
|||
651 |
// 12.x renamed this inadvertently, so alias it for consistency within the |
||
652 |
// release line, while using the original name for consistency with older |
||
653 |
// release lines. |
||
654 |
4944 |
AddOption("--security-revert", "", &PerProcessOptions::security_reverts); |
|
655 |
4944 |
AddAlias("--security-reverts", "--security-revert"); |
|
656 |
AddOption("--completion-bash", |
||
657 |
"print source-able bash completion script", |
||
658 |
4944 |
&PerProcessOptions::print_bash_completion); |
|
659 |
AddOption("--help", |
||
660 |
"print node command line options", |
||
661 |
4944 |
&PerProcessOptions::print_help); |
|
662 |
4944 |
AddAlias("-h", "--help"); |
|
663 |
AddOption( |
||
664 |
4944 |
"--version", "print Node.js version", &PerProcessOptions::print_version); |
|
665 |
4944 |
AddAlias("-v", "--version"); |
|
666 |
AddOption("--v8-options", |
||
667 |
"print V8 command line options", |
||
668 |
4944 |
&PerProcessOptions::print_v8_help); |
|
669 |
|||
670 |
#ifdef NODE_HAVE_I18N_SUPPORT |
||
671 |
AddOption("--icu-data-dir", |
||
672 |
"set ICU data load path to dir (overrides NODE_ICU_DATA)" |
||
673 |
#ifndef NODE_HAVE_SMALL_ICU |
||
674 |
" (note: linked-in ICU data is present)\n" |
||
675 |
#endif |
||
676 |
, |
||
677 |
&PerProcessOptions::icu_data_dir, |
||
678 |
4944 |
kAllowedInEnvironment); |
|
679 |
#endif |
||
680 |
|||
681 |
#if HAVE_OPENSSL |
||
682 |
AddOption("--openssl-config", |
||
683 |
"load OpenSSL configuration from the specified file " |
||
684 |
"(overrides OPENSSL_CONF)", |
||
685 |
&PerProcessOptions::openssl_config, |
||
686 |
4944 |
kAllowedInEnvironment); |
|
687 |
AddOption("--tls-cipher-list", |
||
688 |
"use an alternative default TLS cipher list", |
||
689 |
&PerProcessOptions::tls_cipher_list, |
||
690 |
4944 |
kAllowedInEnvironment); |
|
691 |
AddOption("--use-openssl-ca", |
||
692 |
"use OpenSSL's default CA store" |
||
693 |
#if defined(NODE_OPENSSL_CERT_STORE) |
||
694 |
" (default)" |
||
695 |
#endif |
||
696 |
, |
||
697 |
&PerProcessOptions::use_openssl_ca, |
||
698 |
4944 |
kAllowedInEnvironment); |
|
699 |
AddOption("--use-bundled-ca", |
||
700 |
"use bundled CA store" |
||
701 |
#if !defined(NODE_OPENSSL_CERT_STORE) |
||
702 |
" (default)" |
||
703 |
#endif |
||
704 |
, |
||
705 |
&PerProcessOptions::use_bundled_ca, |
||
706 |
4944 |
kAllowedInEnvironment); |
|
707 |
// Similar to [has_eval_string] above, except that the separation between |
||
708 |
// this and use_openssl_ca only exists for option validation after parsing. |
||
709 |
// This is not ideal. |
||
710 |
AddOption("[ssl_openssl_cert_store]", |
||
711 |
"", |
||
712 |
4944 |
&PerProcessOptions::ssl_openssl_cert_store); |
|
713 |
4944 |
Implies("--use-openssl-ca", "[ssl_openssl_cert_store]"); |
|
714 |
4944 |
ImpliesNot("--use-bundled-ca", "[ssl_openssl_cert_store]"); |
|
715 |
#if NODE_FIPS_MODE |
||
716 |
AddOption("--enable-fips", |
||
717 |
"enable FIPS crypto at startup", |
||
718 |
&PerProcessOptions::enable_fips_crypto, |
||
719 |
kAllowedInEnvironment); |
||
720 |
AddOption("--force-fips", |
||
721 |
"force FIPS crypto (cannot be disabled)", |
||
722 |
&PerProcessOptions::force_fips_crypto, |
||
723 |
kAllowedInEnvironment); |
||
724 |
#endif |
||
725 |
#endif |
||
726 |
|||
727 |
4944 |
Insert(iop, &PerProcessOptions::get_per_isolate_options); |
|
728 |
4944 |
} |
|
729 |
|||
730 |
110 |
inline std::string RemoveBrackets(const std::string& host) { |
|
731 |
✓✗✓✓ ✓✓✓✓ |
110 |
if (!host.empty() && host.front() == '[' && host.back() == ']') |
732 |
4 |
return host.substr(1, host.size() - 2); |
|
733 |
else |
||
734 |
106 |
return host; |
|
735 |
} |
||
736 |
|||
737 |
98 |
inline int ParseAndValidatePort(const std::string& port, |
|
738 |
std::vector<std::string>* errors) { |
||
739 |
char* endptr; |
||
740 |
98 |
errno = 0; |
|
741 |
const unsigned long result = // NOLINT(runtime/int) |
||
742 |
98 |
strtoul(port.c_str(), &endptr, 10); |
|
743 |
✓✗✓✗ ✓✓ |
98 |
if (errno != 0 || *endptr != '\0'|| |
744 |
✓✗✗✓ |
63 |
(result != 0 && result < 1024) || result > 65535) { |
745 |
errors->push_back(" must be 0 or in range 1024 to 65535."); |
||
746 |
} |
||
747 |
98 |
return static_cast<int>(result); |
|
748 |
} |
||
749 |
|||
750 |
98 |
HostPort SplitHostPort(const std::string& arg, |
|
751 |
std::vector<std::string>* errors) { |
||
752 |
// remove_brackets only works if no port is specified |
||
753 |
// so if it has an effect only an IPv6 address was specified. |
||
754 |
98 |
std::string host = RemoveBrackets(arg); |
|
755 |
✗✓ | 98 |
if (host.length() < arg.length()) |
756 |
return HostPort{host, DebugOptions::kDefaultInspectorPort}; |
||
757 |
|||
758 |
98 |
size_t colon = arg.rfind(':'); |
|
759 |
✓✓ | 98 |
if (colon == std::string::npos) { |
760 |
// Either a port number or a host name. Assume that |
||
761 |
// if it's not all decimal digits, it's a host name. |
||
762 |
✓✓ | 386 |
for (char c : arg) { |
763 |
✓✗✗✓ |
300 |
if (c < '0' || c > '9') { |
764 |
return HostPort{arg, DebugOptions::kDefaultInspectorPort}; |
||
765 |
} |
||
766 |
} |
||
767 |
86 |
return HostPort { "", ParseAndValidatePort(arg, errors) }; |
|
768 |
} |
||
769 |
// Host and port found: |
||
770 |
return HostPort { RemoveBrackets(arg.substr(0, colon)), |
||
771 |
12 |
ParseAndValidatePort(arg.substr(colon + 1), errors) }; |
|
772 |
} |
||
773 |
|||
774 |
// Return a map containing all the options and their metadata as well |
||
775 |
// as the aliases |
||
776 |
5092 |
void GetOptions(const FunctionCallbackInfo<Value>& args) { |
|
777 |
5092 |
Mutex::ScopedLock lock(per_process::cli_options_mutex); |
|
778 |
5092 |
Environment* env = Environment::GetCurrent(args); |
|
779 |
✗✓ | 5092 |
if (!env->has_run_bootstrapping_code()) { |
780 |
// No code because this is an assertion. |
||
781 |
return env->ThrowError( |
||
782 |
"Should not query options before bootstrapping is done"); |
||
783 |
} |
||
784 |
5092 |
env->set_has_serialized_options(true); |
|
785 |
|||
786 |
5092 |
Isolate* isolate = env->isolate(); |
|
787 |
5092 |
Local<Context> context = env->context(); |
|
788 |
|||
789 |
// Temporarily act as if the current Environment's/IsolateData's options were |
||
790 |
// the default options, i.e. like they are the ones we'd access for global |
||
791 |
// options parsing, so that all options are available from the main parser. |
||
792 |
✓✗ | 10184 |
auto original_per_isolate = per_process::cli_options->per_isolate; |
793 |
5092 |
per_process::cli_options->per_isolate = env->isolate_data()->options(); |
|
794 |
✓✗ | 10184 |
auto original_per_env = per_process::cli_options->per_isolate->per_env; |
795 |
5092 |
per_process::cli_options->per_isolate->per_env = env->options(); |
|
796 |
5092 |
OnScopeLeave on_scope_leave([&]() { |
|
797 |
5092 |
per_process::cli_options->per_isolate->per_env = original_per_env; |
|
798 |
5092 |
per_process::cli_options->per_isolate = original_per_isolate; |
|
799 |
✓✗ | 15276 |
}); |
800 |
|||
801 |
5092 |
Local<Map> options = Map::New(isolate); |
|
802 |
✓✓ | 493924 |
for (const auto& item : _ppop_instance.options_) { |
803 |
Local<Value> value; |
||
804 |
488832 |
const auto& option_info = item.second; |
|
805 |
488832 |
auto field = option_info.field; |
|
806 |
488832 |
PerProcessOptions* opts = per_process::cli_options.get(); |
|
807 |
✓✓✓✓ ✓✓✓✗ |
488832 |
switch (option_info.type) { |
808 |
case kNoOp: |
||
809 |
case kV8Option: |
||
810 |
// Special case for --abort-on-uncaught-exception which is also |
||
811 |
// respected by Node.js internals |
||
812 |
✓✓ | 56012 |
if (item.first == "--abort-on-uncaught-exception") { |
813 |
value = Boolean::New( |
||
814 |
10184 |
isolate, original_per_env->abort_on_uncaught_exception); |
|
815 |
} else { |
||
816 |
50920 |
value = Undefined(isolate); |
|
817 |
} |
||
818 |
56012 |
break; |
|
819 |
case kBoolean: |
||
820 |
value = Boolean::New(isolate, |
||
821 |
560120 |
*_ppop_instance.Lookup<bool>(field, opts)); |
|
822 |
280060 |
break; |
|
823 |
case kInteger: |
||
824 |
value = Number::New(isolate, |
||
825 |
10184 |
*_ppop_instance.Lookup<int64_t>(field, opts)); |
|
826 |
5092 |
break; |
|
827 |
case kUInteger: |
||
828 |
value = Number::New(isolate, |
||
829 |
30552 |
*_ppop_instance.Lookup<uint64_t>(field, opts)); |
|
830 |
15276 |
break; |
|
831 |
case kString: |
||
832 |
✗✓ | 234232 |
if (!ToV8Value(context, |
833 |
234232 |
*_ppop_instance.Lookup<std::string>(field, opts)) |
|
834 |
351348 |
.ToLocal(&value)) { |
|
835 |
return; |
||
836 |
} |
||
837 |
117116 |
break; |
|
838 |
case kStringList: |
||
839 |
✗✓ | 20368 |
if (!ToV8Value(context, |
840 |
20368 |
*_ppop_instance.Lookup<StringVector>(field, opts)) |
|
841 |
30552 |
.ToLocal(&value)) { |
|
842 |
return; |
||
843 |
} |
||
844 |
10184 |
break; |
|
845 |
case kHostPort: { |
||
846 |
const HostPort& host_port = |
||
847 |
5092 |
*_ppop_instance.Lookup<HostPort>(field, opts); |
|
848 |
5092 |
Local<Object> obj = Object::New(isolate); |
|
849 |
Local<Value> host; |
||
850 |
✓✗✓✗ ✗✓ |
30552 |
if (!ToV8Value(context, host_port.host()).ToLocal(&host) || |
851 |
✓✗✗✓ ✓✗✓✗ |
45828 |
obj->Set(context, env->host_string(), host).IsNothing() || |
852 |
obj->Set(context, |
||
853 |
env->port_string(), |
||
854 |
✓✗✓✗ |
20368 |
Integer::New(isolate, host_port.port())) |
855 |
✓✗ | 25460 |
.IsNothing()) { |
856 |
return; |
||
857 |
} |
||
858 |
5092 |
value = obj; |
|
859 |
5092 |
break; |
|
860 |
} |
||
861 |
default: |
||
862 |
UNREACHABLE(); |
||
863 |
} |
||
864 |
✗✓ | 488832 |
CHECK(!value.IsEmpty()); |
865 |
|||
866 |
977664 |
Local<Value> name = ToV8Value(context, item.first).ToLocalChecked(); |
|
867 |
488832 |
Local<Object> info = Object::New(isolate); |
|
868 |
Local<Value> help_text; |
||
869 |
✓✗✓✗ ✗✓ |
3421824 |
if (!ToV8Value(context, option_info.help_text).ToLocal(&help_text) || |
870 |
✓✗ | 1466496 |
!info->Set(context, env->help_text_string(), help_text) |
871 |
✓✗✓✗ ✓✗ |
4399488 |
.FromMaybe(false) || |
872 |
!info->Set(context, |
||
873 |
env->env_var_settings_string(), |
||
874 |
Integer::New(isolate, |
||
875 |
✓✗✓✗ |
1955328 |
static_cast<int>(option_info.env_setting))) |
876 |
✓✗✓✗ ✓✗ |
4888320 |
.FromMaybe(false) || |
877 |
!info->Set(context, |
||
878 |
env->type_string(), |
||
879 |
✓✗✓✗ |
1955328 |
Integer::New(isolate, static_cast<int>(option_info.type))) |
880 |
✓✗✓✗ ✓✗ |
4399488 |
.FromMaybe(false) || |
881 |
✓✗✗✓ ✓✗✓✗ |
4888320 |
info->Set(context, env->value_string(), value).IsNothing() || |
882 |
✓✗✓✗ |
1955328 |
options->Set(context, name, info).IsEmpty()) { |
883 |
return; |
||
884 |
} |
||
885 |
488832 |
} |
|
886 |
|||
887 |
Local<Value> aliases; |
||
888 |
✗✓ | 10184 |
if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return; |
889 |
|||
890 |
5092 |
Local<Object> ret = Object::New(isolate); |
|
891 |
✓✗✗✓ ✓✗✓✗ ✓✗✗✓ |
40736 |
if (ret->Set(context, env->options_string(), options).IsNothing() || |
892 |
✓✗✓✗ |
25460 |
ret->Set(context, env->aliases_string(), aliases).IsNothing()) { |
893 |
return; |
||
894 |
} |
||
895 |
|||
896 |
✓✗ | 15276 |
args.GetReturnValue().Set(ret); |
897 |
} |
||
898 |
|||
899 |
5092 |
void Initialize(Local<Object> target, |
|
900 |
Local<Value> unused, |
||
901 |
Local<Context> context, |
||
902 |
void* priv) { |
||
903 |
5092 |
Environment* env = Environment::GetCurrent(context); |
|
904 |
5092 |
Isolate* isolate = env->isolate(); |
|
905 |
5092 |
env->SetMethodNoSideEffect(target, "getOptions", GetOptions); |
|
906 |
|||
907 |
5092 |
Local<Object> env_settings = Object::New(isolate); |
|
908 |
20368 |
NODE_DEFINE_CONSTANT(env_settings, kAllowedInEnvironment); |
|
909 |
20368 |
NODE_DEFINE_CONSTANT(env_settings, kDisallowedInEnvironment); |
|
910 |
target |
||
911 |
->Set( |
||
912 |
15276 |
context, FIXED_ONE_BYTE_STRING(isolate, "envSettings"), env_settings) |
|
913 |
10184 |
.Check(); |
|
914 |
|||
915 |
5092 |
Local<Object> types = Object::New(isolate); |
|
916 |
20368 |
NODE_DEFINE_CONSTANT(types, kNoOp); |
|
917 |
20368 |
NODE_DEFINE_CONSTANT(types, kV8Option); |
|
918 |
20368 |
NODE_DEFINE_CONSTANT(types, kBoolean); |
|
919 |
20368 |
NODE_DEFINE_CONSTANT(types, kInteger); |
|
920 |
20368 |
NODE_DEFINE_CONSTANT(types, kUInteger); |
|
921 |
20368 |
NODE_DEFINE_CONSTANT(types, kString); |
|
922 |
20368 |
NODE_DEFINE_CONSTANT(types, kHostPort); |
|
923 |
20368 |
NODE_DEFINE_CONSTANT(types, kStringList); |
|
924 |
15276 |
target->Set(context, FIXED_ONE_BYTE_STRING(isolate, "types"), types) |
|
925 |
10184 |
.Check(); |
|
926 |
5092 |
} |
|
927 |
|||
928 |
} // namespace options_parser |
||
929 |
} // namespace node |
||
930 |
|||
931 |
✓✗✓✗ |
19775 |
NODE_MODULE_CONTEXT_AWARE_INTERNAL(options, node::options_parser::Initialize) |
Generated by: GCOVR (Version 3.4) |