46 lines
2.9 KiB
JavaScript
46 lines
2.9 KiB
JavaScript
"use strict";
|
|
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) {
|
|
let execCommand = this.createExecString(commandArg);
|
|
return smartshellWrap.execSilent(commandArg);
|
|
}
|
|
/**
|
|
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5jbGFzc2VzLnNtYXJ0c2hlbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNoZWxsLmNsYXNzZXMuc21hcnRzaGVsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLG9EQUFtRDtBQVVuRDtJQUdFLFlBQWEsVUFBd0M7UUFEckQsb0JBQWUsR0FBYSxFQUFFLENBQUE7UUFFNUIsSUFBSSxDQUFD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