@@ -30,6 +30,7 @@ const {
3030const { internalBinding, NativeModule } = loaderExports ;
3131
3232const exceptionHandlerState = { captureFn : null } ;
33+ let getOptionValue ;
3334
3435function startup ( ) {
3536 setupTraceCategoryState ( ) ;
@@ -105,7 +106,7 @@ function startup() {
105106 NativeModule . require ( 'internal/inspector_async_hook' ) . setup ( ) ;
106107 }
107108
108- const { getOptionValue } = NativeModule . require ( 'internal/options' ) ;
109+ getOptionValue = NativeModule . require ( 'internal/options' ) . getOptionValue ;
109110
110111 if ( getOptionValue ( '--help' ) ) {
111112 NativeModule . require ( 'internal/print_help' ) . print ( process . stdout ) ;
@@ -241,8 +242,7 @@ function startExecution() {
241242 }
242243
243244 // `node --prof-process`
244- // TODO(joyeecheung): use internal/options instead of process.profProcess
245- if ( process . profProcess ) {
245+ if ( getOptionValue ( '--prof-process' ) ) {
246246 NativeModule . require ( 'internal/v8_prof_processor' ) ;
247247 return ;
248248 }
@@ -264,13 +264,12 @@ function prepareUserCodeExecution() {
264264 }
265265
266266 // For user code, we preload modules if `-r` is passed
267- // TODO(joyeecheung): use internal/options instead of
268- // process._preload_modules
269- if ( process . _preload_modules ) {
267+ const preloadModules = getOptionValue ( '--require' ) ;
268+ if ( preloadModules ) {
270269 const {
271270 _preloadModules
272271 } = NativeModule . require ( 'internal/modules/cjs/loader' ) ;
273- _preloadModules ( process . _preload_modules ) ;
272+ _preloadModules ( preloadModules ) ;
274273 }
275274}
276275
@@ -279,14 +278,12 @@ function executeUserCode() {
279278 // `--interactive`.
280279 // Note that the name `forceRepl` is merely an alias of `interactive`
281280 // in code.
282- // TODO(joyeecheung): use internal/options instead of
283- // process._eval/process._forceRepl
284- if ( process . _eval != null && ! process . _forceRepl ) {
281+ if ( getOptionValue ( '[has_eval_string]' ) && ! getOptionValue ( '--interactive' ) ) {
285282 const {
286283 addBuiltinLibsToObject
287284 } = NativeModule . require ( 'internal/modules/cjs/helpers' ) ;
288285 addBuiltinLibsToObject ( global ) ;
289- evalScript ( '[eval]' , wrapForBreakOnFirstLine ( process . _eval ) ) ;
286+ evalScript ( '[eval]' , wrapForBreakOnFirstLine ( getOptionValue ( '--eval' ) ) ) ;
290287 return ;
291288 }
292289
@@ -300,9 +297,7 @@ function executeUserCode() {
300297
301298 // If user passed `-c` or `--check` arguments to Node, check its syntax
302299 // instead of actually running the file.
303- // TODO(joyeecheung): use internal/options instead of
304- // process._syntax_check_only
305- if ( process . _syntax_check_only != null ) {
300+ if ( getOptionValue ( '--check' ) ) {
306301 const fs = NativeModule . require ( 'fs' ) ;
307302 // Read the source.
308303 const filename = CJSModule . _resolveFilename ( process . argv [ 1 ] ) ;
@@ -668,7 +663,7 @@ function evalScript(name, body) {
668663 `${ JSON . stringify ( body ) } , { filename: ` +
669664 `${ JSON . stringify ( name ) } , displayErrors: true });\n` ;
670665 const result = module . _compile ( script , `${ name } -wrapper` ) ;
671- if ( process . _print_eval ) console . log ( result ) ;
666+ if ( getOptionValue ( '--print' ) ) console . log ( result ) ;
672667 // Handle any nextTicks added in the first tick of the program.
673668 process . _tickCallback ( ) ;
674669}
0 commit comments