Welcome to mirror list, hosted at ThFree Co, Russian Federation.

stdin_messages.js « message « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b32004c329dead99286decd3797f081f7c0516db (plain)
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';

require('../common');

const spawn = require('child_process').spawn;

function run(cmd, strict, cb) {
  const args = [];
  if (strict) args.push('--use_strict');
  args.push('-p');
  const child = spawn(process.execPath, args);
  child.stdout.pipe(process.stdout);
  child.stderr.pipe(process.stdout);
  child.stdin.end(cmd);
  child.on('close', cb);
}

const queue =
  [ 'with(this){__filename}',
    '42',
    'throw new Error("hello")',
    'var x = 100; y = x;',
    'var ______________________________________________; throw 10' ];

function go() {
  const c = queue.shift();
  if (!c) return console.log('done');
  run(c, false, function() {
    run(c, true, go);
  });
}

go();