@@ -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 ) ;
@@ -241,8 +242,7 @@ function startExecution() {
241
242
}
242
243
243
244
// `node --prof-process`
244
- // TODO(joyeecheung): use internal/options instead of process.profProcess
245
- if ( process . profProcess ) {
245
+ if ( getOptionValue ( '--prof-process' ) ) {
246
246
NativeModule . require ( 'internal/v8_prof_processor' ) ;
247
247
return ;
248
248
}
@@ -264,13 +264,12 @@ function prepareUserCodeExecution() {
264
264
}
265
265
266
266
// 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 ) {
270
269
const {
271
270
_preloadModules
272
271
} = NativeModule . require ( 'internal/modules/cjs/loader' ) ;
273
- _preloadModules ( process . _preload_modules ) ;
272
+ _preloadModules ( preloadModules ) ;
274
273
}
275
274
}
276
275
@@ -279,14 +278,12 @@ function executeUserCode() {
279
278
// `--interactive`.
280
279
// Note that the name `forceRepl` is merely an alias of `interactive`
281
280
// 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' ) ) {
285
282
const {
286
283
addBuiltinLibsToObject
287
284
} = NativeModule . require ( 'internal/modules/cjs/helpers' ) ;
288
285
addBuiltinLibsToObject ( global ) ;
289
- evalScript ( '[eval]' , wrapForBreakOnFirstLine ( process . _eval ) ) ;
286
+ evalScript ( '[eval]' , wrapForBreakOnFirstLine ( getOptionValue ( '--eval' ) ) ) ;
290
287
return ;
291
288
}
292
289
@@ -300,9 +297,7 @@ function executeUserCode() {
300
297
301
298
// If user passed `-c` or `--check` arguments to Node, check its syntax
302
299
// 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' ) ) {
306
301
const fs = NativeModule . require ( 'fs' ) ;
307
302
// Read the source.
308
303
const filename = CJSModule . _resolveFilename ( process . argv [ 1 ] ) ;
@@ -668,7 +663,7 @@ function evalScript(name, body) {
668
663
`${ JSON . stringify ( body ) } , { filename: ` +
669
664
`${ JSON . stringify ( name ) } , displayErrors: true });\n` ;
670
665
const result = module . _compile ( script , `${ name } -wrapper` ) ;
671
- if ( process . _print_eval ) console . log ( result ) ;
666
+ if ( getOptionValue ( '--print' ) ) console . log ( result ) ;
672
667
// Handle any nextTicks added in the first tick of the program.
673
668
process . _tickCallback ( ) ;
674
669
}
0 commit comments