forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheval_stdin.js
More file actions
33 lines (26 loc) · 790 Bytes
/
eval_stdin.js
File metadata and controls
33 lines (26 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
// Stdin is not a TTY, we will read it and execute it.
const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');
const { getOptionValue } = require('internal/options');
const {
evalModule,
evalScript,
readStdin
} = require('internal/process/execution');
prepareMainThreadExecution();
markBootstrapComplete();
readStdin((code) => {
// This is necessary for fork() and CJS module compilation.
// TODO(joyeecheung): pass this with something really internal.
process._eval = code;
const print = getOptionValue('--print');
if (getOptionValue('--input-type') === 'module')
evalModule(code, print);
else
evalScript('[stdin]',
code,
getOptionValue('--inspect-brk'),
print);
});