src/utils/exec.js
function exec(cmd, args = [], silent = false) {
    return __awaiter(this, void 0, void 0, function* () {
        const response = [];
        return new Promise((resolve, reject) => {
            const exe = child_process_1.spawn(cmd, args, {
                env: process.env
            });
            exe.stdout.on('data', data => {
                response.push(data.toString());
                if (!silent) {
                    console.log(data.toString());
                }
            });
            exe.stderr.on('data', data => {
                if (!silent) {
                    console.error(data.toString());
                }
            });
            exe.on('exit', code => {
                if (code === 0) {
                    return resolve(response);
                }
                else {
                    if (!silent) {
                        console.error('Problem executing ' + cmd);
                    }
                    return reject();
                }
            });
        });
    });
}
function exec(cmd, args = [], silent = false) {
    return __awaiter(this, void 0, void 0, function* () {
        const response = [];
        return new Promise((resolve, reject) => {
            const exe = child_process_1.spawn(cmd, args, {
                env: process.env
            });
            exe.stdout.on('data', data => {
                response.push(data.toString());
                if (!silent) {
                    console.log(data.toString());
                }
            });
            exe.stderr.on('data', data => {
                if (!silent) {
                    console.error(data.toString());
                }
            });
            exe.on('exit', code => {
                if (code === 0) {
                    return resolve(response);
                }
                else {
                    if (!silent) {
                        console.error('Problem executing ' + cmd);
                    }
                    return reject();
                }
            });
        });
    });
}
function exec ( cmd , args = [ ] , silent = false ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { const response = [ ] ; return new Promise ( ( resolve , reject ) => { const exe = child_process_1 . spawn ( cmd , args , { env : process . env } ) ; exe . stdout . on ( 'data' , data => { response . push ( data . toString ( ) ) ; if ( ! silent ) { console . log ( data . toString ( ) ) ; } } ) ; exe . stderr . on ( 'data' , data => { if ( ! silent ) { console . error ( data . toString ( ) ) ; } } ) ; exe . on ( 'exit' , code => { if ( code === 0 ) { return resolve ( response ) ; } else { if ( ! silent ) { console . error ( 'Problem executing ' + cmd ) ; } return reject ( ) ; } } ) ; } ) ; } ) ; }
Execute a CMD line process
Execute a CMD line process