Skip to content

Commit 0183570

Browse files
joyeecheungrefack
authored andcommitted
process: move --help and --bash-completeion handling to startExecution
Because they are similar to `--prof-process` and are part of the execution instead of initialization. Also move the `getOptionValue` initialization to top scope since it's used everywhere and add comments about the flags. PR-URL: nodejs#25262 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent f6d29a0 commit 0183570

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/internal/bootstrap/node.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
const { internalBinding, NativeModule } = loaderExports;
2020

21-
let getOptionValue;
21+
const { getOptionValue } = NativeModule.require('internal/options');
2222

2323
function startup() {
2424
setupTraceCategoryState();
@@ -168,18 +168,6 @@ function startup() {
168168
NativeModule.require('internal/inspector_async_hook').setup();
169169
}
170170

171-
getOptionValue = NativeModule.require('internal/options').getOptionValue;
172-
173-
if (getOptionValue('--help')) {
174-
NativeModule.require('internal/print_help').print(process.stdout);
175-
return;
176-
}
177-
178-
if (getOptionValue('--completion-bash')) {
179-
NativeModule.require('internal/bash_completion').print(process.stdout);
180-
return;
181-
}
182-
183171
// If the process is spawned with env NODE_CHANNEL_FD, it's probably
184172
// spawned by our child_process module, then initialize IPC.
185173
// This attaches some internal event listeners and creates:
@@ -360,6 +348,18 @@ function startExecution() {
360348
return;
361349
}
362350

351+
// node --help
352+
if (getOptionValue('--help')) {
353+
NativeModule.require('internal/print_help').print(process.stdout);
354+
return;
355+
}
356+
357+
// e.g. node --completion-bash >> ~/.bashrc
358+
if (getOptionValue('--completion-bash')) {
359+
NativeModule.require('internal/bash_completion').print(process.stdout);
360+
return;
361+
}
362+
363363
// `node --prof-process`
364364
if (getOptionValue('--prof-process')) {
365365
NativeModule.require('internal/v8_prof_processor');

0 commit comments

Comments
 (0)