• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 'use strict';
2 
3 // Stdin is not a TTY, we will read it and execute it.
4 
5 const {
6   prepareMainThreadExecution
7 } = require('internal/bootstrap/pre_execution');
8 
9 const { getOptionValue } = require('internal/options');
10 
11 const {
12   evalModule,
13   evalScript,
14   readStdin
15 } = require('internal/process/execution');
16 
17 prepareMainThreadExecution();
18 markBootstrapComplete();
19 
20 readStdin((code) => {
21   // This is necessary for fork() and CJS module compilation.
22   // TODO(joyeecheung): pass this with something really internal.
23   process._eval = code;
24 
25   const print = getOptionValue('--print');
26   if (getOptionValue('--input-type') === 'module')
27     evalModule(code, print);
28   else
29     evalScript('[stdin]',
30                code,
31                getOptionValue('--inspect-brk'),
32                print);
33 });
34