Files
test-repo/tests/flow/node_tests/child_process/spawn.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

31 lines
627 B
JavaScript

/* @flow */
var child_process = require('child_process');
var ls = child_process.spawn('ls');
var wc = child_process.spawn('wc', ['-l']);
// args + options.
child_process.spawn('echo', ['-n', '"Testing..."'], {env: {TEST: 'foo'}});
// options only.
child_process.spawn('echo', {env: {FOO: 2}});
ls.stdout.on('data', function(data) {
wc.stdin.write(data);
});
ls.stderr.on('data', function(data) {
console.warn(data);
});
ls.on('close', function(code) {
if (code !== 0) {
console.warn('`ls` exited with code %s', code);
}
wc.stdin.end();
});
wc.stdout.pipe(process.stdout);
wc.stderr.pipe(process.stderr);