Last active
August 11, 2017 16:36
-
-
Save bidiu/eca9fc953bc0b96a4e3dbf2d5580b6e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { exec } = require('child_process'); | |
module.exports = function execCmd(cmd, { fromDir = '.' } = {}) { | |
return new Promise((resolve, reject) => { | |
exec(`cd ${fromDir} & ${cmd}`, (error, stdout, stderr) => { | |
if (!error) { | |
resolve(stdout); | |
} else { | |
reject({ error: error, stderr: stderr }); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment