Skip to content
Myr

add `execa.stdout()` shortcut (#14)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by Sindre Sorhus · parent 5fe7261 · Browse files · 4 files+35 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+35 added−0 removed

  • other:+35 added−0 removed

4 files+35 added−0 removed

added:fixtures/noop-err+3 added
1#!/usr/bin/env node2'use strict';3console.error(process.argv[2]);
modified:index.js+14 added
modified:readme.md+8 added
63 unmodified lines
64Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess).6566The `child_process` instance is enhanced to also be promise for a result object with `stdout` and `stderr` properties.6768### execa.stdout(file, [arguments], [options])6970Same as `execa()`, but returns only `stdout`.7172### execa.stderr(file, [arguments], [options])7374Same as `execa()`, but returns only `stderr`.7576### execa.shell(command, [options])7778Execute a command through the system shell. Prefer `execa()` whenever possible, as it's both faster and safer.79
58 unmodified lines
modified:test.js+10 added
15 unmodified lines
16 t.true(Buffer.isBuffer(stdout));17 t.is(stdout.toString(), 'foo');18});1920test('execa.stdout()', async t => {21 const stdout = await m.stdout('noop', ['foo']);22 t.is(stdout, 'foo');23});2425test('execa.stderr()', async t => {26 const stderr = await m.stderr('noop-err', ['foo']);27 t.is(stderr, 'foo');28});2930test('stdout/stderr available on errors', async t => {31 const err = await t.throws(m('exit', ['2']));32 t.is(typeof err.stdout, 'string');33 t.is(typeof err.stderr, 'string');
93 unmodified lines