summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-12-15 20:50:42 +0100
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-12-21 07:18:05 +0100
commit8b5720833f1a48bcfe9072305682bea76f833ab4 (patch)
treeaa537a07e49a9fa679055144c07eeae5b0f56b42 /lib
parent0461e4cd9b3d637f53dec9c6336220d69c7178b0 (diff)
downloadandroid-node-v8-8b5720833f1a48bcfe9072305682bea76f833ab4.tar.gz
android-node-v8-8b5720833f1a48bcfe9072305682bea76f833ab4.tar.bz2
android-node-v8-8b5720833f1a48bcfe9072305682bea76f833ab4.zip
src,lib: prefer internal/options over process._foo
This addresses a couple `TODO` comments and allows us to remove a number of underscored properties from `process` (in a semver-major follow-up). PR-URL: https://github.com/nodejs/node/pull/25063 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/bootstrap/node.js25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index c70deafb08..c51961e9ce 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -29,6 +29,7 @@ const {
const { internalBinding, NativeModule } = loaderExports;
const exceptionHandlerState = { captureFn: null };
+let getOptionValue;
function startup() {
setupTraceCategoryState();
@@ -117,7 +118,7 @@ function startup() {
NativeModule.require('internal/inspector_async_hook').setup();
}
- const { getOptionValue } = NativeModule.require('internal/options');
+ getOptionValue = NativeModule.require('internal/options').getOptionValue;
if (getOptionValue('--help')) {
NativeModule.require('internal/print_help').print(process.stdout);
@@ -253,8 +254,7 @@ function startExecution() {
}
// `node --prof-process`
- // TODO(joyeecheung): use internal/options instead of process.profProcess
- if (process.profProcess) {
+ if (getOptionValue('--prof-process')) {
NativeModule.require('internal/v8_prof_processor');
return;
}
@@ -276,13 +276,12 @@ function prepareUserCodeExecution() {
}
// For user code, we preload modules if `-r` is passed
- // TODO(joyeecheung): use internal/options instead of
- // process._preload_modules
- if (process._preload_modules) {
+ const preloadModules = getOptionValue('--require');
+ if (preloadModules) {
const {
_preloadModules
} = NativeModule.require('internal/modules/cjs/loader');
- _preloadModules(process._preload_modules);
+ _preloadModules(preloadModules);
}
}
@@ -291,14 +290,12 @@ function executeUserCode() {
// `--interactive`.
// Note that the name `forceRepl` is merely an alias of `interactive`
// in code.
- // TODO(joyeecheung): use internal/options instead of
- // process._eval/process._forceRepl
- if (process._eval != null && !process._forceRepl) {
+ if (getOptionValue('[has_eval_string]') && !getOptionValue('--interactive')) {
const {
addBuiltinLibsToObject
} = NativeModule.require('internal/modules/cjs/helpers');
addBuiltinLibsToObject(global);
- evalScript('[eval]', wrapForBreakOnFirstLine(process._eval));
+ evalScript('[eval]', wrapForBreakOnFirstLine(getOptionValue('--eval')));
return;
}
@@ -312,9 +309,7 @@ function executeUserCode() {
// If user passed `-c` or `--check` arguments to Node, check its syntax
// instead of actually running the file.
- // TODO(joyeecheung): use internal/options instead of
- // process._syntax_check_only
- if (process._syntax_check_only != null) {
+ if (getOptionValue('--check')) {
const fs = NativeModule.require('fs');
// Read the source.
const filename = CJSModule._resolveFilename(process.argv[1]);
@@ -661,7 +656,7 @@ function evalScript(name, body) {
`${JSON.stringify(body)}, { filename: ` +
`${JSON.stringify(name)}, displayErrors: true });\n`;
const result = module._compile(script, `${name}-wrapper`);
- if (process._print_eval) console.log(result);
+ if (getOptionValue('--print')) console.log(result);
// Handle any nextTicks added in the first tick of the program.
process._tickCallback();
}