1 | const chalk = require("chalk");
|
2 | const tryPath = process.cwd();
|
3 |
|
4 | const 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 |
|
19 | module.exports = execCommand;
|