0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/lib/internal/main/eval_string.js
Joyee Cheung 49ee010005
lib: use getOptionValue instead of process underscore aliases
This patch reduce usage of `process._breakFirstLine` and
`process._eval` in the internals and use
`getOptionValue('--inspect-brk')` and `getOptionValue('--eval')`
instead wherever possible.

PR-URL: https://github.com/nodejs/node/pull/27278
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-04-20 00:20:37 +08:00

27 lines
760 B
JavaScript

'use strict';
// User passed `-e` or `--eval` arguments to Node without `-i` or
// `--interactive`.
const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');
const { evalModule, evalScript } = require('internal/process/execution');
const { addBuiltinLibsToObject } = require('internal/modules/cjs/helpers');
const { getOptionValue } = require('internal/options');
prepareMainThreadExecution();
addBuiltinLibsToObject(global);
markBootstrapComplete();
const source = getOptionValue('--eval');
const print = getOptionValue('--print');
if (getOptionValue('--input-type') === 'module')
evalModule(source, print);
else
evalScript('[eval]',
source,
getOptionValue('--inspect-brk'),
print);