Code coverage report for tasks/utils/exec.js

Statements: 100% (10 / 10)      Branches: 66.67% (4 / 6)      Functions: 100% (3 / 3)      Lines: 100% (10 / 10)      Ignored: none     

All files » tasks/utils/ » exec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211 1   1   2 2   2 2 2 1   1              
var Promise = require('es6-promise').Promise;
var child_process = require('child_process');
 
module.exports = {
    exec : function execPromise(cmd, args){
        return new Promise(function(resolve, reject){
            child_process.exec(cmd + ' ' + args.join(' '),
                function (error, stdout, stderr) {
                    stdout && console.log(stdout);
                    stderr && console.log(stderr);
                    if (error !== null) {
                        reject( cmd + ' ' + args[0] + ' Error: ' + error);
                    } else {
                        resolve(cmd + ' ' + args[0] + ' Complete');
                    }
                });
        });
    }
};