| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b1500d9 commit 37ba201
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ const { | |||
| 30 | 30 | const { internalBinding, NativeModule } = loaderExports; | |
| 31 | 31 | ||
| 32 | 32 | const exceptionHandlerState = { captureFn: null }; | |
| 33 | + let getOptionValue; | ||
| 33 | 34 | ||
| 34 | 35 | function startup() { | |
| 35 | 36 | setupTraceCategoryState(); | |
@@ -105,7 +106,7 @@ function startup() { | |||
| 105 | 106 | NativeModule.require('internal/inspector_async_hook').setup(); | |
| 106 | 107 | } | |
| 107 | 108 | ||
| 108 | - const { getOptionValue } = NativeModule.require('internal/options'); | ||
| 109 | + getOptionValue = NativeModule.require('internal/options').getOptionValue; | ||
| 109 | 110 | ||
| 110 | 111 | if (getOptionValue('--help')) { | |
| 111 | 112 | NativeModule.require('internal/print_help').print(process.stdout); | |
@@ -265,8 +266,7 @@ function startExecution() { | |||
| 265 | 266 | } | |
| 266 | 267 | ||
| 267 | 268 | // `node --prof-process` | |
| 268 | - // TODO(joyeecheung): use internal/options instead of process.profProcess | ||
| 269 | - if (process.profProcess) { | ||
| 269 | + if (getOptionValue('--prof-process')) { | ||
| 270 | 270 | NativeModule.require('internal/v8_prof_processor'); | |
| 271 | 271 | return; | |
| 272 | 272 | } | |
@@ -288,13 +288,12 @@ function prepareUserCodeExecution() { | |||
| 288 | 288 | } | |
| 289 | 289 | ||
| 290 | 290 | // For user code, we preload modules if `-r` is passed | |
| 291 | - // TODO(joyeecheung): use internal/options instead of | ||
| 292 | - // process._preload_modules | ||
| 293 | - if (process._preload_modules) { | ||
| 291 | + const preloadModules = getOptionValue('--require'); | ||
| 292 | + if (preloadModules) { | ||
| 294 | 293 | const { | |
| 295 | 294 | _preloadModules | |
| 296 | 295 | } = NativeModule.require('internal/modules/cjs/loader'); | |
| 297 | - _preloadModules(process._preload_modules); | ||
| 296 | + _preloadModules(preloadModules); | ||
| 298 | 297 | } | |
| 299 | 298 | } | |
| 300 | 299 | ||
@@ -303,14 +302,12 @@ function executeUserCode() { | |||
| 303 | 302 | // `--interactive`. | |
| 304 | 303 | // Note that the name `forceRepl` is merely an alias of `interactive` | |
| 305 | 304 | // in code. | |
| 306 | - // TODO(joyeecheung): use internal/options instead of | ||
| 307 | - // process._eval/process._forceRepl | ||
| 308 | - if (process._eval != null && !process._forceRepl) { | ||
| 305 | + if (getOptionValue('[has_eval_string]') && !getOptionValue('--interactive')) { | ||
| 309 | 306 | const { | |
| 310 | 307 | addBuiltinLibsToObject | |
| 311 | 308 | } = NativeModule.require('internal/modules/cjs/helpers'); | |
| 312 | 309 | addBuiltinLibsToObject(global); | |
| 313 | - evalScript('[eval]', wrapForBreakOnFirstLine(process._eval)); | ||
| 310 | + evalScript('[eval]', wrapForBreakOnFirstLine(getOptionValue('--eval'))); | ||
| 314 | 311 | return; | |
| 315 | 312 | } | |
| 316 | 313 | ||
@@ -324,9 +321,7 @@ function executeUserCode() { | |||
| 324 | 321 | ||
| 325 | 322 | // If user passed `-c` or `--check` arguments to Node, check its syntax | |
| 326 | 323 | // instead of actually running the file. | |
| 327 | - // TODO(joyeecheung): use internal/options instead of | ||
| 328 | - // process._syntax_check_only | ||
| 329 | - if (process._syntax_check_only != null) { | ||
| 324 | + if (getOptionValue('--check')) { | ||
| 330 | 325 | const fs = NativeModule.require('fs'); | |
| 331 | 326 | // Read the source. | |
| 332 | 327 | const filename = CJSModule._resolveFilename(process.argv[1]); | |
@@ -682,7 +677,7 @@ function evalScript(name, body) { | |||
| 682 | 677 | `${JSON.stringify(body)}, { filename: ` + | |
| 683 | 678 | `${JSON.stringify(name)}, displayErrors: true });\n`; | |
| 684 | 679 | const result = module._compile(script, `${name}-wrapper`); | |
| 685 | - if (process._print_eval) console.log(result); | ||
| 680 | + if (getOptionValue('--print')) console.log(result); | ||
| 686 | 681 | // Handle any nextTicks added in the first tick of the program. | |
| 687 | 682 | process._tickCallback(); | |
| 688 | 683 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1002,6 +1002,7 @@ void SetupProcessObject(Environment* env, | |||
| 1002 | 1002 | GetParentProcessId).FromJust()); | |
| 1003 | 1003 | ||
| 1004 | 1004 | // -e, --eval | |
| 1005 | + // TODO(addaleax): Remove this. | ||
| 1005 | 1006 | if (env->options()->has_eval_string) { | |
| 1006 | 1007 | READONLY_PROPERTY(process, | |
| 1007 | 1008 | "_eval", | |
@@ -1012,23 +1013,27 @@ void SetupProcessObject(Environment* env, | |||
| 1012 | 1013 | } | |
| 1013 | 1014 | ||
| 1014 | 1015 | // -p, --print | |
| 1016 | + // TODO(addaleax): Remove this. | ||
| 1015 | 1017 | if (env->options()->print_eval) { | |
| 1016 | 1018 | READONLY_PROPERTY(process, "_print_eval", True(env->isolate())); | |
| 1017 | 1019 | } | |
| 1018 | 1020 | ||
| 1019 | 1021 | // -c, --check | |
| 1022 | + // TODO(addaleax): Remove this. | ||
| 1020 | 1023 | if (env->options()->syntax_check_only) { | |
| 1021 | 1024 | READONLY_PROPERTY(process, "_syntax_check_only", True(env->isolate())); | |
| 1022 | 1025 | } | |
| 1023 | 1026 | ||
| 1024 | 1027 | // -i, --interactive | |
| 1028 | + // TODO(addaleax): Remove this. | ||
| 1025 | 1029 | if (env->options()->force_repl) { | |
| 1026 | 1030 | READONLY_PROPERTY(process, "_forceRepl", True(env->isolate())); | |
| 1027 | 1031 | } | |
| 1028 | 1032 | ||
| 1029 | 1033 | // -r, --require | |
| 1030 | - std::vector<std::string> preload_modules = | ||
| 1031 | - std::move(env->options()->preload_modules); | ||
| 1034 | + // TODO(addaleax): Remove this. | ||
| 1035 | + const std::vector<std::string>& preload_modules = | ||
| 1036 | + env->options()->preload_modules; | ||
| 1032 | 1037 | if (!preload_modules.empty()) { | |
| 1033 | 1038 | Local<Array> array = Array::New(env->isolate()); | |
| 1034 | 1039 | for (unsigned int i = 0; i < preload_modules.size(); ++i) { | |
@@ -1041,8 +1046,6 @@ void SetupProcessObject(Environment* env, | |||
| 1041 | 1046 | READONLY_PROPERTY(process, | |
| 1042 | 1047 | "_preload_modules", | |
| 1043 | 1048 | array); | |
| 1044 | - | ||
| 1045 | - preload_modules.clear(); | ||
| 1046 | 1049 | } | |
| 1047 | 1050 | ||
| 1048 | 1051 | // --no-deprecation | |
@@ -1071,6 +1074,7 @@ void SetupProcessObject(Environment* env, | |||
| 1071 | 1074 | #endif // NODE_NO_BROWSER_GLOBALS | |
| 1072 | 1075 | ||
| 1073 | 1076 | // --prof-process | |
| 1077 | + // TODO(addaleax): Remove this. | ||
| 1074 | 1078 | if (env->options()->prof_process) { | |
| 1075 | 1079 | READONLY_PROPERTY(process, "profProcess", True(env->isolate())); | |
| 1076 | 1080 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments