"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
class Shell {
    execSpawn(cmd, args = [], options = {
        stdout: (data) => process.stdout.write(data.toString()),
        stderr: (data) => process.stderr.write(data.toString()),
    }) {
        return new Promise((resolve, reject) => {
            //kick off process of listing files
            var child = child_process_1.spawn(cmd, args, {
                cwd: process.cwd(),
                shell: true
            });
            child.on('error', (err) => {
                reject(err);
            });
            //spit stdout to screen
            child.stdout.on('data', options.stdout);
            //spit stderr to screen
            child.stderr.on('data', options.stderr);
            child.on('close', function (code) {
                resolve(code);
            });
        });
    }
    exec(arg0) {
        return new Promise((resolve, reject) => {
            try {
                let res = this.execSync(arg0);
                resolve(res);
            }
            catch (err) {
                reject(err);
            }
        });
    }
    execSync(cmd) {
        let result = child_process_1.execSync(cmd);
        console.info(`cmd ${cmd} => ${result}`);
        return result;
    }
    hasCommand(cmd) {
        return true;
    }
}
exports.Shell = Shell;
exports.shell = new Shell();
//# sourceMappingURL=shell.js.map