mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00

PR-URL: https://github.com/nodejs/node/pull/35086 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
26 lines
556 B
JavaScript
26 lines
556 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const os = require('os');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
const { pipeline } = require('stream');
|
|
pipeline(
|
|
process.stdin,
|
|
process.stdout,
|
|
common.mustSucceed()
|
|
);
|
|
} else {
|
|
const cp = require('child_process');
|
|
cp.exec([
|
|
'echo',
|
|
'hello',
|
|
'|',
|
|
`"${process.execPath}"`,
|
|
`"${__filename}"`,
|
|
'child'
|
|
].join(' '), common.mustSucceed((stdout) => {
|
|
assert.strictEqual(stdout.split(os.EOL).shift().trim(), 'hello');
|
|
}));
|
|
}
|