smartshell/dist/smartshell.classes.smartshell.js

66 lines
4.1 KiB
JavaScript
Raw Normal View History

2017-03-10 19:14:40 +00:00
"use strict";
2017-03-11 00:58:09 +00:00
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());
});
};
2017-03-10 19:14:40 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2017-03-10 21:08:04 +00:00
const smartshellWrap = require("./smartshell.wrap");
2017-03-10 19:14:40 +00:00
class Smartshell {
constructor(optionsArg) {
2017-03-10 21:08:04 +00:00
this.sourceFileArray = [];
this.executor = optionsArg.executor;
2017-03-10 19:14:40 +00:00
for (let sourceFilePath of optionsArg.sourceFilePaths) {
2017-03-10 21:08:04 +00:00
this.sourceFileArray.push(sourceFilePath);
2017-03-10 19:14:40 +00:00
}
}
addSourceFiles(sourceFilePathsArray) {
for (let sourceFilePath of sourceFilePathsArray) {
2017-03-10 21:08:04 +00:00
this.sourceFileArray.push(sourceFilePath);
2017-03-10 19:14:40 +00:00
}
}
cleanSourceFiles() {
2017-03-10 21:08:04 +00:00
this.sourceFileArray = [];
}
/**
* executes silently and returns IExecResult
* @param commandArg
*/
execSilent(commandArg) {
2017-03-11 00:58:09 +00:00
return __awaiter(this, void 0, void 0, function* () {
let execCommand = this.createExecString(commandArg);
2017-03-11 01:57:46 +00:00
return yield smartshellWrap.execSilent(execCommand);
2017-03-11 00:58:09 +00:00
});
2017-03-10 21:08:04 +00:00
}
2017-03-11 01:36:27 +00:00
/**
* executes and returns IExecResult
* @param commandArg
*/
exec(commandArg) {
return __awaiter(this, void 0, void 0, function* () {
let execCommand = this.createExecString(commandArg);
2017-03-11 01:57:46 +00:00
return yield smartshellWrap.exec(execCommand);
2017-03-11 01:36:27 +00:00
});
}
2017-03-10 21:08:04 +00:00
/**
* 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;
}
2017-03-10 19:14:40 +00:00
}
}
exports.Smartshell = Smartshell;
2017-06-27 08:28:11 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5jbGFzc2VzLnNtYXJ0c2hlbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNoZWxsLmNsYXNzZXMuc21hcnRzaGVsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQ0Esb0RBQW1EO0FBVW5EO0lBR0UsWUFBYSxVQUF3QztRQURyRCxvQkFBZSxHQUFhLEVBQUUsQ0FBQTtRQUU1QixJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUE7UUFDbkMsR0FBRyxDQUFDLENBQUMsSUFBSSxjQUFjLElBQUksVUFBVSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUM7WUFDdEQsSUFBSSxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUE7UUFDM0MsQ0FBQztJQUNILENBQUM7SUFFRCxjQUFjLENBQUUsb0JBQThCO1FBQzVDLEdBQUcsQ0FBQyxDQUFDLElBQUksY0FBYyxJQUFJLG9CQUFvQixDQUFDLENBQUMsQ0FBQztZQUNoRCxJQUFJLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQTtRQUMzQyxDQUFDO0lBQ0gsQ0FBQztJQUVELGdCQUFnQjtRQ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