smartshell/dist/smartshell.classes.smartshell.js
PhilKunz External 63d5fe4f1c Dev
2017-06-27 08:28:11 +00:00

66 lines
4.1 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const smartshellWrap = require("./smartshell.wrap");
class Smartshell {
constructor(optionsArg) {
this.sourceFileArray = [];
this.executor = optionsArg.executor;
for (let sourceFilePath of optionsArg.sourceFilePaths) {
this.sourceFileArray.push(sourceFilePath);
}
}
addSourceFiles(sourceFilePathsArray) {
for (let sourceFilePath of sourceFilePathsArray) {
this.sourceFileArray.push(sourceFilePath);
}
}
cleanSourceFiles() {
this.sourceFileArray = [];
}
/**
* executes silently and returns IExecResult
* @param commandArg
*/
execSilent(commandArg) {
return __awaiter(this, void 0, void 0, function* () {
let execCommand = this.createExecString(commandArg);
return yield smartshellWrap.execSilent(execCommand);
});
}
/**
* executes and returns IExecResult
* @param commandArg
*/
exec(commandArg) {
return __awaiter(this, void 0, void 0, function* () {
let execCommand = this.createExecString(commandArg);
return yield smartshellWrap.exec(execCommand);
});
}
/**
* creates the final sourcing string
* @param commandArg
*/
createExecString(commandArg) {
if (this.executor === 'bash') {
let sourceString = '';
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
return `bash -c '${sourceString} ${commandArg}'`;
}
else {
return commandArg;
}
}
}
exports.Smartshell = Smartshell;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5jbGFzc2VzLnNtYXJ0c2hlbGwuanMiLCJz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