Skip to content

Instantly share code, notes, and snippets.

@skarfacegc
Created April 2, 2017 19:31
Show Gist options
  • Save skarfacegc/b9e3e568eb2ac72decb59b5ea59f14cc to your computer and use it in GitHub Desktop.
Save skarfacegc/b9e3e568eb2ac72decb59b5ea59f14cc to your computer and use it in GitHub Desktop.
execa Stream and Promise example
'use strict';
const execa = require('execa');
const getStream = require('get-stream');
let foo = execa.shell('sleep 3 && echo foo');
foo.then((result)=>{
console.log('Done');
console.log(result);
})
foo.stdout.on('data', (chunk)=>{
console.log('+++ ' + chunk);
});
getStream(foo.stdout).then((result)=>{
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment