Skip to content

Instantly share code, notes, and snippets.

@toboid
Created June 18, 2017 15:20
Show Gist options
  • Save toboid/3cc455d10b1e62c5607266bf2253ee9d to your computer and use it in GitHub Desktop.
Save toboid/3cc455d10b1e62c5607266bf2253ee9d to your computer and use it in GitHub Desktop.
util.promisify where callback takes multiple arguments
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