"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.spawnSync=spawnSync,exports.spawnSyncExecShell=spawnSyncExecShell;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),env_1=require("./env");function spawnSync(e,n,o,s){return new Promise((c,r)=>{null==s||s.progress(`Run command: ${e} ${n.join(" ")}...`);const t=child_process.spawn(e,n,Object.assign({env:(0,env_1.getProcessEnv)()},o));t.stdout.on("data",e=>{null==s||s.progress(e.toString("utf-8"))}),t.stderr.on("data",e=>{null==s||s.progress(e.toString("utf-8"))}),t.on("close",o=>{0!==o?(null==s||s.message("doing",`Failed to exec command: ${e} ${n.join(" ")}`),r(`Failed to exec command: ${e} ${n.join(" ")}`)):(null==s||s.message("success",`Successful to exec command: ${e} ${n.join(" ")}`),c({}))}),t.on("error",o=>{null==s||s.message("doing",`Failed to exec command: ${e} ${n.join(" ")} becasue ${o}`),r(`Failed to exec command: ${e} ${n.join(" ")}`)})})}function spawnSyncExecShell(e,n,o,s){return new Promise((c,r)=>{null==s||s.progress(`Run command: ${e} ${n.join(" ")}...`);const t=child_process.spawn(e,n,Object.assign({env:(0,env_1.getProcessEnv)()},o));t.stdout.on("data",e=>{null==s||s.progress(e.toString("utf-8"))}),t.stderr.on("data",e=>{null==s||s.message("error",e.toString("utf-8"))}),t.on("close",o=>{0!==o?r(`Failed to exec command: ${e} ${n.join(" ")}`):(null==s||s.progress(`Successful to exec command: ${e} ${n.join(" ")}`),c({}))}),t.on("error",o=>{r(`Failed to exec command: ${e} ${n.join(" ")} becasue ${o}`)})})}