@@ -29,6 +29,7 @@ const {
29
29
const { internalBinding, NativeModule } = loaderExports ;
30
30
31
31
const exceptionHandlerState = { captureFn : null } ;
32
+ let getOptionValue ;
32
33
33
34
function startup ( ) {
34
35
setupTraceCategoryState ( ) ;
@@ -117,7 +118,7 @@ function startup() {
117
118
NativeModule . require ( 'internal/inspector_async_hook' ) . setup ( ) ;
118
119
}
119
120
120
- const { getOptionValue } = NativeModule . require ( 'internal/options' ) ;
121
+ getOptionValue = NativeModule . require ( 'internal/options' ) . getOptionValue ;
121
122
122
123
if ( getOptionValue ( '--help' ) ) {
123
124
NativeModule . require ( 'internal/print_help' ) . print ( process . stdout ) ;
@@ -253,8 +254,7 @@ function startExecution() {
253
254
}
254
255
255
256
// `node --prof-process`
256
- // TODO(joyeecheung): use internal/options instead of process.profProcess
257
- if ( process . profProcess ) {
257
+ if ( getOptionValue ( '--prof-process' ) ) {
258
258
NativeModule . require ( 'internal/v8_prof_processor' ) ;
259
259
return ;
260
260
}
@@ -276,13 +276,12 @@ function prepareUserCodeExecution() {
276
276
}
277
277
278
278
// For user code, we preload modules if `-r` is passed
279
- // TODO(joyeecheung): use internal/options instead of
280
- // process._preload_modules
281
- if ( process . _preload_modules ) {
279
+ const preloadModules = getOptionValue ( '--require' ) ;
280
+ if ( preloadModules ) {
282
281
const {
283
282
_preloadModules
284
283
} = NativeModule . require ( 'internal/modules/cjs/loader' ) ;
285
- _preloadModules ( process . _preload_modules ) ;
284
+ _preloadModules ( preloadModules ) ;
286
285
}
287
286
}
288
287
@@ -291,14 +290,12 @@ function executeUserCode() {
291
290
// `--interactive`.
292
291
// Note that the name `forceRepl` is merely an alias of `interactive`
293
292
// in code.
294
- // TODO(joyeecheung): use internal/options instead of
295
- // process._eval/process._forceRepl
296
- if ( process . _eval != null && ! process . _forceRepl ) {
293
+ if ( getOptionValue ( '[has_eval_string]' ) && ! getOptionValue ( '--interactive' ) ) {
297
294
const {
298
295
addBuiltinLibsToObject
299
296
} = NativeModule . require ( 'internal/modules/cjs/helpers' ) ;
300
297
addBuiltinLibsToObject ( global ) ;
301
- evalScript ( '[eval]' , wrapForBreakOnFirstLine ( process . _eval ) ) ;
298
+ evalScript ( '[eval]' , wrapForBreakOnFirstLine ( getOptionValue ( '--eval' ) ) ) ;
302
299
return ;
303
300
}
304
301
@@ -312,9 +309,7 @@ function executeUserCode() {
312
309
313
310
// If user passed `-c` or `--check` arguments to Node, check its syntax
314
311
// instead of actually running the file.
315
- // TODO(joyeecheung): use internal/options instead of
316
- // process._syntax_check_only
317
- if ( process . _syntax_check_only != null ) {
312
+ if ( getOptionValue ( '--check' ) ) {
318
313
const fs = NativeModule . require ( 'fs' ) ;
319
314
// Read the source.
320
315
const filename = CJSModule . _resolveFilename ( process . argv [ 1 ] ) ;
@@ -661,7 +656,7 @@ function evalScript(name, body) {
661
656
`${ JSON . stringify ( body ) } , { filename: ` +
662
657
`${ JSON . stringify ( name ) } , displayErrors: true });\n` ;
663
658
const result = module . _compile ( script , `${ name } -wrapper` ) ;
664
- if ( process . _print_eval ) console . log ( result ) ;
659
+ if ( getOptionValue ( '--print' ) ) console . log ( result ) ;
665
660
// Handle any nextTicks added in the first tick of the program.
666
661
process . _tickCallback ( ) ;
667
662
}
0 commit comments