Skip to content

Commit

Permalink
add execa.stdout() shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 22, 2016
1 parent 71a58ee commit 98fc977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ module.exports = function (cmd, args, opts) {
return promise;
};

module.exports.stdout = function () {
return module.exports.apply(null, arguments).then(function (x) {
return x.stdout;
});
};

module.exports.shell = function (cmd, opts) {
return handleShell(module.exports, cmd, opts);
};
Expand Down
5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ test('buffer', async t => {
t.is(stdout.toString(), 'foo');
});

test('execa.stdout()', async t => {
const stdout = await m.stdout('echo', ['foo']);
t.is(stdout, 'foo');
});

test('stdout/stderr available on errors', async t => {
const err = await t.throws(m('exit', ['2']));
t.is(typeof err.stdout, 'string');
Expand Down

0 comments on commit 98fc977

Please sign in to comment.