function test (file) { file = join('fixtures', 'broken-pipe', file) t.test(file, { parallel: true }, async ({ is }) => { const child = fork(join(__dirname, file), { silent: true }) child.stdout.destroy() child.stderr.pipe(process.stdout) const res = await once(child, 'close') is(res, 0) // process exits successfully }) }
test('do not use SonicBoom is someone tampered with process.stdout.write', async ({ isNot }) => { var actual = '' const child = fork(join(__dirname, 'fixtures', 'stdout-hack-protection.js'), { silent: true }) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/^hack/), null) })
benchmark.stdout.pipe(process.stdout)
child.stdout.pipe(writer((s, enc, cb) => { actual2 += s cb()
}) if (settings.relayStderr) { program.stderr.pipe(process.stderr)
child.stdout.pipe(writer((s, enc, cb) => { actual2 += s cb()
function uploadToGCS(buf, res, gcsStream) { const rs = utils.createReadStream(buf); rs.pipe(gcsStream); rs.on('error', (err) => { log.error(err, 'Error uploading to Google Cloud Storage after compression'); return errors.internalServer(res); }) }
s.pipe( tar.extract('./', { ignore: (name, header) => {
n.stdout.pipe(getTapParser()) .on('error', function (e: Error) { _suman.log.error('error parsing TAP output =>', su.getCleanErrorString(e)); }) .once('finish', function () { n.tapOutputIsComplete = true; process.nextTick(function () { n.emit('tap-output-is-complete', true); }); });
// saves the returned translation audio into a file on disk const saveTranslation = (binary) => { const rs = new stream.Readable(); rs.push(binary); rs.push(null); const file = fs.createWriteStream(path.join(__dirname, 'translation.wav')); rs.pipe(file); }
function echoServer (type, cb) { if (typeof type === 'function') return echoServer('http', type) var script = path.join(__dirname, '_echo_server.js') var cp = exec(`node "${script}" ${type}`) cp.stderr.pipe(process.stderr) cp.stdout.once('data', function (chunk) { var port = chunk.trim().split('\n')[0] cb(cp, port) }) }
const runYarnCommand = (cmd: string) => { const child = spawn('yarn', [cmd], { cwd: __dirname + '/..', env: process.env }); const pid = child.pid; children.push(pid); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on('exit', (code, signal) => { console.log(`${cmd} exited with code ${code} and signal ${signal} (pid: ${pid})`); }); return child; }
// pipes the returned translation audio into the Speaker instance so it plays the sound on your computer! const playTranslation = (binary) => { const rs = new stream.Readable(); rs.push(binary); rs.push(null); rs.pipe(speaker); }