Skip to content

Commit 59b5e77

Browse files
joyeecheungaddaleax
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: #25262 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 2bd7437 commit 59b5e77

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();
@@ -160,18 +160,6 @@ function startup() {
160160
NativeModule.require('internal/inspector_async_hook').setup();
161161
}
162162

163-
getOptionValue = NativeModule.require('internal/options').getOptionValue;
164-
165-
if (getOptionValue('--help')) {
166-
NativeModule.require('internal/print_help').print(process.stdout);
167-
return;
168-
}
169-
170-
if (getOptionValue('--completion-bash')) {
171-
NativeModule.require('internal/bash_completion').print(process.stdout);
172-
return;
173-
}
174-
175163
// If the process is spawned with env NODE_CHANNEL_FD, it's probably
176164
// spawned by our child_process module, then initialize IPC.
177165
// This attaches some internal event listeners and creates:
@@ -376,6 +364,18 @@ function startExecution() {
376364
return;
377365
}
378366

367+
// node --help
368+
if (getOptionValue('--help')) {
369+
NativeModule.require('internal/print_help').print(process.stdout);
370+
return;
371+
}
372+
373+
// e.g. node --completion-bash >> ~/.bashrc
374+
if (getOptionValue('--completion-bash')) {
375+
NativeModule.require('internal/bash_completion').print(process.stdout);
376+
return;
377+
}
378+
379379
// `node --prof-process`
380380
if (getOptionValue('--prof-process')) {
381381
NativeModule.require('internal/v8_prof_processor');

0 commit comments

Comments
 (0)