Created
June 18, 2017 15:20
-
-
Save toboid/3cc455d10b1e62c5607266bf2253ee9d to your computer and use it in GitHub Desktop.
util.promisify where callback takes multiple arguments
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
const {promisify} = require('util'); | |
const child = require('child_process'); | |
const exec = promisify(child.exec); | |
exec('echo "Hello world"').then( | |
result => console.log(result), // Prints { stdout: 'Hello world\n', stderr: '' } | |
error => console.error(error) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment