mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 23:33:38 -05:00
21 lines
701 B
JavaScript
21 lines
701 B
JavaScript
const exec = require('child_process').exec
|
|
const printError = require('./print-error')
|
|
|
|
module.exports = function (args, cmd) {
|
|
if (args.dryRun) return Promise.resolve()
|
|
return new Promise((resolve, reject) => {
|
|
// Exec given cmd and handle possible errors
|
|
exec(cmd, function (err, stdout, stderr) {
|
|
// If exec returns content in stderr, but no error, print it as a warning
|
|
// If exec returns an error, print it and exit with return code 1
|
|
if (err) {
|
|
printError(args, stderr || err.message)
|
|
return reject(err)
|
|
} else if (stderr) {
|
|
printError(args, stderr, {level: 'warn', color: 'yellow'})
|
|
}
|
|
return resolve(stdout)
|
|
})
|
|
})
|
|
}
|