node/lib/internal/main/eval_string.js
Geoffrey Booth 96e46d37c4
esm: replace --entry-type with --input-type
New flag is for string input only

PR-URL: https://github.com/nodejs/node/pull/27184
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-04-16 12:41:59 -04:00

21 lines
656 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');
const source = getOptionValue('--eval');
prepareMainThreadExecution();
addBuiltinLibsToObject(global);
markBootstrapComplete();
if (getOptionValue('--input-type') === 'module')
evalModule(source);
else
evalScript('[eval]', source, process._breakFirstLine);