Created
April 2, 2017 19:31
-
-
Save skarfacegc/b9e3e568eb2ac72decb59b5ea59f14cc to your computer and use it in GitHub Desktop.
execa Stream and Promise example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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