node/lib/internal/main/eval_stdin.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

25 lines
540 B
JavaScript

'use strict';
// Stdin is not a TTY, we will read it and execute it.
const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');
const {
evalModule,
evalScript,
readStdin
} = require('internal/process/execution');
prepareMainThreadExecution();
markBootstrapComplete();
readStdin((code) => {
process._eval = code;
if (require('internal/options').getOptionValue('--input-type') === 'module')
evalModule(process._eval);
else
evalScript('[stdin]', process._eval, process._breakFirstLine);
});