All files / lib/internal/main eval_stdin.js

100% Statements 33/33
100% Branches 4/4
100% Functions 0/0
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 3417x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 16x 16x 16x 16x 16x 17x  
'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);
});