Skip to content

Commit

Permalink
feat: Stream output
Browse files Browse the repository at this point in the history
Pipe output from execa to stdout and stderr.

Closes: #9
  • Loading branch information
mischah committed Feb 11, 2019
1 parent d1527cd commit 65569d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 0 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ if (Object.keys(cli.flags).map(key => typeof cli.flags[key]).some(type => type =
}

errorNotifier(cli.input[0], cli.flags)
.then(result => {
console.log(result.stdout || result.stderr);
})
.catch(error => {
console.error(error.stdout || error.stderr);
process.exit(error.code);
});
6 changes: 4 additions & 2 deletions lib/error-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ module.exports = (command, opts) => {
opts = opts || {};

return new Promise((resolve, reject) => {
execa.shell(command, {env: {FORCE_COLOR: true}})
.then(result => resolve(result))
const execaPending = execa.shell(command, {env: {FORCE_COLOR: true}});
execaPending.stdout.pipe(process.stdout);
execaPending.stderr.pipe(process.stderr);
return execaPending.then(result => resolve(result))
.catch(error => notifier.notify(notifierOptions(opts), () => reject(error)));
});
};

0 comments on commit 65569d7

Please sign in to comment.