diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-29 11:16:01 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-31 15:23:48 +0800 |
commit | ee12607c1cc12f6b366de563004d984a929297b5 (patch) | |
tree | 2ab7ebbf67daddb9fed8d811f954ac4a0f57536e | |
parent | 0878b6172e7d88d30c49ff9f3cc123f40c0678eb (diff) | |
download | android-node-v8-ee12607c1cc12f6b366de563004d984a929297b5.tar.gz android-node-v8-ee12607c1cc12f6b366de563004d984a929297b5.tar.bz2 android-node-v8-ee12607c1cc12f6b366de563004d984a929297b5.zip |
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: https://github.com/nodejs/node/pull/25262
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r-- | lib/internal/bootstrap/node.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 3077365971..db593e597d 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -18,7 +18,7 @@ const { internalBinding, NativeModule } = loaderExports; -let getOptionValue; +const { getOptionValue } = NativeModule.require('internal/options'); function startup() { setupTraceCategoryState(); @@ -168,18 +168,6 @@ function startup() { NativeModule.require('internal/inspector_async_hook').setup(); } - getOptionValue = NativeModule.require('internal/options').getOptionValue; - - if (getOptionValue('--help')) { - NativeModule.require('internal/print_help').print(process.stdout); - return; - } - - if (getOptionValue('--completion-bash')) { - NativeModule.require('internal/bash_completion').print(process.stdout); - return; - } - // If the process is spawned with env NODE_CHANNEL_FD, it's probably // spawned by our child_process module, then initialize IPC. // This attaches some internal event listeners and creates: @@ -360,6 +348,18 @@ function startExecution() { return; } + // node --help + if (getOptionValue('--help')) { + NativeModule.require('internal/print_help').print(process.stdout); + return; + } + + // e.g. node --completion-bash >> ~/.bashrc + if (getOptionValue('--completion-bash')) { + NativeModule.require('internal/bash_completion').print(process.stdout); + return; + } + // `node --prof-process` if (getOptionValue('--prof-process')) { NativeModule.require('internal/v8_prof_processor'); |