Skip to content

Commit

Permalink
process: move --help and --bash-completeion handling to startExecution
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
joyeecheung authored and BridgeAR committed Jan 17, 2019
1 parent 743056e commit 5eada9d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

const { internalBinding, NativeModule } = loaderExports;

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

function startup() {
setupTraceCategoryState();
Expand Down Expand Up @@ -160,18 +160,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:
Expand Down Expand Up @@ -376,6 +364,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');
Expand Down

0 comments on commit 5eada9d

Please sign in to comment.