UNPKG

726 BJavaScriptView Raw
1const chalk = require("chalk");
2const tryPath = process.cwd();
3
4const execCommand = cmdChoice => {
5 console.warn("-- Console WHAT IS INSIDE ", cmdChoice);
6 const { spawn } = require("child_process");
7 let command = cmdChoice.src ? cmdChoice.src : cmdChoice;
8 let dirPath = command.replace("./", tryPath + "/").replace("\n", "");
9 let pars = dirPath.split(" ");
10 const shell = spawn(pars[0], pars.slice(1, pars.length), { stdio: "inherit", cwd: tryPath });
11 return new Promise(resolve => {
12 shell.on("close", code => {
13 console.log(`${chalk.bold.green("Finished")}`);
14 resolve();
15 });
16 });
17};
18///DEVELOPMENT/freedcamp-script-runner/test
19module.exports = execCommand;