All files / lib/internal/main eval_stdin.js

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

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 34 35 36 375x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 18x 18x 18x 18x 18x 18x 18x 18x 17x 17x 17x 17x 17x 17x 5x  
'use strict';
 
// Stdin is not a TTY, we will read it and execute it.
 
const {
  prepareMainThreadExecution,
  markBootstrapComplete
} = require('internal/process/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');
  const loadESM = getOptionValue('--import').length > 0;
  if (getOptionValue('--input-type') === 'module')
    evalModule(code, print);
  else
    evalScript('[stdin]',
               code,
               getOptionValue('--inspect-brk'),
               print,
               loadESM);
});