summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-08 14:39:57 +0100
committerJoyee Cheung <joyeec9h3@gmail.com>2019-03-12 08:00:19 +0800
commit0a95c87dc660f593d532b9daae5ad0b13890b1c8 (patch)
treec707f4050b050f780e7b914c528644dc87a09579 /lib/internal/bootstrap/pre_execution.js
parent728c939e57ec471bf0a114b86074829be622f421 (diff)
downloadandroid-node-v8-0a95c87dc660f593d532b9daae5ad0b13890b1c8.tar.gz
android-node-v8-0a95c87dc660f593d532b9daae5ad0b13890b1c8.tar.bz2
android-node-v8-0a95c87dc660f593d532b9daae5ad0b13890b1c8.zip
process: create legacy process properties during pre-execution
Shim legacy process object properties of CLI options during pre-execution instead of serializing them during bootstrap. PR-URL: https://github.com/nodejs/node/pull/26517 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 95203c470f..04083b53a2 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -57,13 +57,42 @@ function patchProcessObject() {
value: process.argv[0]
});
process.argv[0] = process.execPath;
+
+ // TODO(joyeecheung): most of these should be deprecated and removed,
+ // execpt some that we need to be able to mutate during run time.
+ addReadOnlyProcessAlias('_eval', '--eval');
+ addReadOnlyProcessAlias('_print_eval', '--print');
+ addReadOnlyProcessAlias('_syntax_check_only', '--check');
+ addReadOnlyProcessAlias('_forceRepl', '--interactive');
+ addReadOnlyProcessAlias('_preload_modules', '--require');
+ addReadOnlyProcessAlias('noDeprecation', '--no-deprecation');
+ addReadOnlyProcessAlias('noProcessWarnings', '--no-warnings');
+ addReadOnlyProcessAlias('traceProcessWarnings', '--trace-warnings');
+ addReadOnlyProcessAlias('throwDeprecation', '--throw-deprecation');
+ addReadOnlyProcessAlias('profProcess', '--prof-process');
+ addReadOnlyProcessAlias('traceDeprecation', '--trace-deprecation');
+ addReadOnlyProcessAlias('_breakFirstLine', '--inspect-brk', false);
+ addReadOnlyProcessAlias('_breakNodeFirstLine', '--inspect-brk-node', false);
+}
+
+function addReadOnlyProcessAlias(name, option, enumerable = true) {
+ const value = getOptionValue(option);
+ if (value) {
+ Object.defineProperty(process, name, {
+ writable: false,
+ configurable: true,
+ enumerable,
+ value
+ });
+ }
}
function setupWarningHandler() {
const {
onWarning
} = require('internal/process/warning');
- if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') {
+ if (!getOptionValue('--no-warnings') &&
+ process.env.NODE_NO_WARNINGS !== '1') {
process.on('warning', onWarning);
}
}