UNPKG

@gabrielvgx/tecfoodcli

Version:

Projeto para automatizar criação de ambientes TecFood

45 lines (34 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _path = _interopRequireDefault(require("path")); var _child_process = require("child_process"); var _app = require("./app.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const terminal = { rootPath: (0, _app.getAppRootPath)(), shellScriptsPath: _path.default.join('src', 'util', 'scripts'), async execute(command, args = null, isScript = false) { return new Promise((resolve, reject) => { let prefixCommand = `/bin/bash `; let suffixCommand = ``; if (isScript) { const SCRIPT_NAME = command; command = _path.default.join(this.rootPath, this.shellScriptsPath, SCRIPT_NAME); } else { prefixCommand += `-c "`; suffixCommand += `"`; } if (args !== null) { command = `${command} ${args}`; } (0, _child_process.exec)(`${prefixCommand}${command}${suffixCommand}`, function (err, stdout, stderr) { if (err || stderr) reject(stderr);else resolve(stdout); }); }); } }; var _default = terminal; exports.default = _default;