test.serial('buffer: false > promise does not resolve when output is big and "all" is used but not read', async t => { const subprocess = execa('max-buffer', {buffer: false, all: true, timeout: BUFFER_TIMEOUT}); subprocess.stdout.resume(); subprocess.stderr.resume(); const {timedOut} = await t.throwsAsync(subprocess); t.true(timedOut); });
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 }) }
let spawn = async function(command, args, options) { let cb = (resolve, reject) => { let exe = ChildProcess.spawn(command, args, options); exe.stdout.on('data', (data) => $.util.log(data.toString('utf8').trim())); exe.stderr.on('data', (err) => onError(err.toString('utf8'))); exe.on('close', resolve); exe.on('error', reject); }; return new Promise(cb); }
writeTerminalData(stream, data) { const buffer = Buffer.from(data, 'base64'); if (stream === 'stderr') process.stderr.write(buffer); else if (stream === 'stdout') process.stdout.write(buffer); }
static writeError(params, color) { // istanbul ignore else if (process.stderr.isTTY) { console.error.apply(null, ColorConsole.formatColor(params, color)); // eslint-disable-line no-console } else { console.error.apply(null, params); // eslint-disable-line no-console } }
const exec = (cmd, args) => { // Use `Observable` support if merged https://github.com/sindresorhus/execa/pull/26 const cp = execa(cmd, args); return merge( streamToObservable(cp.stdout.pipe(split())), streamToObservable(cp.stderr.pipe(split())), cp ).pipe(filter(Boolean)); }
constructor(fmt, options = {}) { if (typeof options === 'number') { options = { total: options }; } this.fmt = fmt === undefined ? ':bar :etas' : fmt; this.stream = options.stream || process.stderr; this.curr = 0; this.total = options.total || 100; this.width = options.width || Math.min(this.total, 50); }
function runCodemod( codemodName, transformTargets ) { const binArgs = [ ...config.jscodeshiftArgs, ...generateBinArgs( codemodName ), ...transformTargets, ]; process.stdout.write( `\nRunning ${ codemodName } on ${ transformTargets.join( ' ' ) }\n` ); child_process.spawnSync( jscodeshiftBin, binArgs, { stdio: [ 'ignore', process.stdout, process.stderr ], } ); }
constructor() { super(); _.each([['stdout', process.stdout], ['stderr', process.stderr]], ([name, stream]) => { stream.write = ((stream) => { return (chunk, encoding, fd) => { this.emit(name, { data: chunk, encoding: encoding, fd: fd }); }; })(stream); }); }
function createWorker (filename) { const filepath = path.join(__dirname, filename) const workerPath = require.resolve(filepath) return new Worker(workerPath, { numWorkers: sysinfo.cpus.physical, forkOptions: { stdio: ['pipe', 'pipe', process.stderr, 'ipc'] } }) }
command.stderr.on('data', data => { data = (data || '').toString(); data = data.split('\n').map(d => `[${type}${n ? ' ' + n : ''}] ${d}`).join('\n'); process.stdout.write(data + '\n'); });
test('buffer: false > promise resolves when output is big and is read', async t => { const subprocess = execa('max-buffer', {buffer: false}); subprocess.stdout.resume(); subprocess.stderr.resume(); await t.notThrowsAsync(subprocess); });
function createWorker (filename) { const filepath = path.join(__dirname, filename) const workerPath = require.resolve(filepath) return new Worker(workerPath, { numWorkers: sysinfo.cpus.physical, forkOptions: { stdio: ['pipe', 'pipe', process.stderr, 'ipc'] } }) }