@@ -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
}
0 commit comments