@@ -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 ) ;
@@ -265,8 +266,7 @@ function startExecution() {
265266 }
266267
267268 // `node --prof-process`
268- // TODO(joyeecheung): use internal/options instead of process.profProcess
269- if ( process . profProcess ) {
269+ if ( getOptionValue ( '--prof-process' ) ) {
270270 NativeModule . require ( 'internal/v8_prof_processor' ) ;
271271 return ;
272272 }
@@ -288,13 +288,12 @@ function prepareUserCodeExecution() {
288288 }
289289
290290 // 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 ) {
294293 const {
295294 _preloadModules
296295 } = NativeModule . require ( 'internal/modules/cjs/loader' ) ;
297- _preloadModules ( process . _preload_modules ) ;
296+ _preloadModules ( preloadModules ) ;
298297 }
299298}
300299
@@ -303,14 +302,12 @@ function executeUserCode() {
303302 // `--interactive`.
304303 // Note that the name `forceRepl` is merely an alias of `interactive`
305304 // 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' ) ) {
309306 const {
310307 addBuiltinLibsToObject
311308 } = NativeModule . require ( 'internal/modules/cjs/helpers' ) ;
312309 addBuiltinLibsToObject ( global ) ;
313- evalScript ( '[eval]' , wrapForBreakOnFirstLine ( process . _eval ) ) ;
310+ evalScript ( '[eval]' , wrapForBreakOnFirstLine ( getOptionValue ( '--eval' ) ) ) ;
314311 return ;
315312 }
316313
@@ -324,9 +321,7 @@ function executeUserCode() {
324321
325322 // If user passed `-c` or `--check` arguments to Node, check its syntax
326323 // 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' ) ) {
330325 const fs = NativeModule . require ( 'fs' ) ;
331326 // Read the source.
332327 const filename = CJSModule . _resolveFilename ( process . argv [ 1 ] ) ;
@@ -682,7 +677,7 @@ function evalScript(name, body) {
682677 `${ JSON . stringify ( body ) } , { filename: ` +
683678 `${ JSON . stringify ( name ) } , displayErrors: true });\n` ;
684679 const result = module . _compile ( script , `${ name } -wrapper` ) ;
685- if ( process . _print_eval ) console . log ( result ) ;
680+ if ( getOptionValue ( '--print' ) ) console . log ( result ) ;
686681 // Handle any nextTicks added in the first tick of the program.
687682 process . _tickCallback ( ) ;
688683}
0 commit comments