add smart sourcing of files with bash
This commit is contained in:
parent
a91938e463
commit
2d3a4b0a0e
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +1,2 @@
|
|||||||
export * from './smartshell.wrap';
|
export * from './smartshell.wrap';
|
||||||
|
export * from './smartshell.classes.smartshell';
|
||||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -4,4 +4,5 @@ function __export(m) {
|
|||||||
}
|
}
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
__export(require("./smartshell.wrap"));
|
__export(require("./smartshell.wrap"));
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHVDQUFpQyJ9
|
__export(require("./smartshell.classes.smartshell"));
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHVDQUFpQztBQUNqQyxxREFBK0MifQ==
|
14
dist/smartshell.classes.smartshell.d.ts
vendored
14
dist/smartshell.classes.smartshell.d.ts
vendored
@ -1,11 +1,23 @@
|
|||||||
|
import * as smartshellWrap from './smartshell.wrap';
|
||||||
export declare type TExecutor = 'sh' | 'bash';
|
export declare type TExecutor = 'sh' | 'bash';
|
||||||
export interface ISmartshellContructorOptions {
|
export interface ISmartshellContructorOptions {
|
||||||
executor: TExecutor;
|
executor: TExecutor;
|
||||||
sourceFilePaths: string[];
|
sourceFilePaths: string[];
|
||||||
}
|
}
|
||||||
export declare class Smartshell {
|
export declare class Smartshell {
|
||||||
sourceFiles: string[];
|
executor: TExecutor;
|
||||||
|
sourceFileArray: string[];
|
||||||
constructor(optionsArg: ISmartshellContructorOptions);
|
constructor(optionsArg: ISmartshellContructorOptions);
|
||||||
addSourceFiles(sourceFilePathsArray: string[]): void;
|
addSourceFiles(sourceFilePathsArray: string[]): void;
|
||||||
cleanSourceFiles(): void;
|
cleanSourceFiles(): void;
|
||||||
|
/**
|
||||||
|
* executes silently and returns IExecResult
|
||||||
|
* @param commandArg
|
||||||
|
*/
|
||||||
|
execSilent(commandArg: string): Promise<smartshellWrap.IExecResult>;
|
||||||
|
/**
|
||||||
|
* creates the final sourcing string
|
||||||
|
* @param commandArg
|
||||||
|
*/
|
||||||
|
private createExecString(commandArg);
|
||||||
}
|
}
|
||||||
|
36
dist/smartshell.classes.smartshell.js
vendored
36
dist/smartshell.classes.smartshell.js
vendored
@ -1,20 +1,46 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const smartshellWrap = require("./smartshell.wrap");
|
||||||
class Smartshell {
|
class Smartshell {
|
||||||
constructor(optionsArg) {
|
constructor(optionsArg) {
|
||||||
this.sourceFiles = [];
|
this.sourceFileArray = [];
|
||||||
|
this.executor = optionsArg.executor;
|
||||||
for (let sourceFilePath of optionsArg.sourceFilePaths) {
|
for (let sourceFilePath of optionsArg.sourceFilePaths) {
|
||||||
this.sourceFiles.push(sourceFilePath);
|
this.sourceFileArray.push(sourceFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addSourceFiles(sourceFilePathsArray) {
|
addSourceFiles(sourceFilePathsArray) {
|
||||||
for (let sourceFilePath of sourceFilePathsArray) {
|
for (let sourceFilePath of sourceFilePathsArray) {
|
||||||
this.sourceFiles.push(sourceFilePath);
|
this.sourceFileArray.push(sourceFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleanSourceFiles() {
|
cleanSourceFiles() {
|
||||||
this.sourceFiles = [];
|
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;
|
exports.Smartshell = Smartshell;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5jbGFzc2VzLnNtYXJ0c2hlbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNoZWxsLmNsYXNzZXMuc21hcnRzaGVsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQVdBO0lBRUUsWUFBYSxVQUF3QztRQURyRCxnQkFBVyxHQUFhLEVBQUUsQ0FBQTtRQUV4QixHQUFHLENBQUMsQ0FBQyxJQUFJLGNBQWMsSUFBSSxVQUFVLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQztZQUN0RCxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQTtRQUN2QyxDQUFDO0lBQ0gsQ0FBQztJQUVELGNBQWMsQ0FBQyxvQkFBOEI7UUFDM0MsR0FBRyxDQUFBLENBQUMsSUF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VBQUUsQ0FBQTtJQUMzQixDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsVUFBVSxDQUFDLFVBQWtCO1FBQzNCLElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUNuRCxNQUFNLENBQUMsY0FBYyxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUM5QyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ssZ0JBQWdCLENBQUUsVUFBVTtRQUNsQyxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxLQUFLLE1BQU0sQ0FBQyxDQUFDLENBQUM7WUFDN0IsSUFBSSxZQUFZLEdBQUcsRUFBRSxDQUFBO1lBQ3JCLEdBQUcsQ0FBQyxDQUFDLElBQUksY0FBYyxJQUFJLElBQUksQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDO2dCQUNoRCxZQUFZLEdBQUcsWUFBWSxHQUFHLFVBQVUsY0FBYyxNQUFNLENBQUE7WUFDOUQsQ0FBQztZQUNELE1BQU0sQ0FBQyxZQUFZLFlBQVksSUFBSSxVQUFVLEdBQUcsQ0FBQTtRQUNsRCxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixNQUFNLENBQUMsVUFBVSxDQUFBO1FBQ25CLENBQUM7SUFDSCxDQUFDO0NBQ0Y7QUE1Q0QsZ0NBNENDIn0=
|
10
test/test.js
10
test/test.js
@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
require("typings-test");
|
require("typings-test");
|
||||||
const smartchai_1 = require("smartchai");
|
const smartchai_1 = require("smartchai");
|
||||||
const smartshell = require("../dist/index");
|
const smartshell = require("../dist/index");
|
||||||
|
let testSmartshell;
|
||||||
describe('smartshell', function () {
|
describe('smartshell', function () {
|
||||||
it('it should run async', function () {
|
it('it should run async', function () {
|
||||||
this.timeout(1000000);
|
this.timeout(1000000);
|
||||||
@ -22,5 +23,12 @@ describe('smartshell', function () {
|
|||||||
});
|
});
|
||||||
return execStreamingResponse.finalPromise;
|
return execStreamingResponse.finalPromise;
|
||||||
});
|
});
|
||||||
|
it('should create a Smartshell instance', function () {
|
||||||
|
testSmartshell = new smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
sourceFilePaths: []
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3QkFBcUI7QUFDckIseUNBQWtDO0FBRWxDLDRDQUEyQztBQUUzQyxRQUFRLENBQUMsWUFBWSxFQUFFO0lBQ3JCLEVBQUUsQ0FBQyxxQkFBcUIsRUFBRTtRQUN4QixJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFBO1FBQ3JCLE1BQU0sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVU7WUFDL0Msa0JBQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUNoRCxDQUFDLENBQUMsQ0FBQTtJQUNKLENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLDZCQUE2QixFQUFFO1FBQ2hDLE1BQU0sQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVU7WUFDckQsa0JBQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUNoRCxDQUFDLENBQUM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FDLENBQUMsQ0FBQTtBQUNKLENBQUMsQ0FBQyxDQUFBIn0=
|
@ -3,6 +3,8 @@ import { expect } from 'smartchai'
|
|||||||
|
|
||||||
import * as smartshell from '../dist/index'
|
import * as smartshell from '../dist/index'
|
||||||
|
|
||||||
|
let testSmartshell: smartshell.Smartshell
|
||||||
|
|
||||||
describe('smartshell', function () {
|
describe('smartshell', function () {
|
||||||
it('it should run async', function () {
|
it('it should run async', function () {
|
||||||
this.timeout(1000000)
|
this.timeout(1000000)
|
||||||
@ -22,4 +24,11 @@ describe('smartshell', function () {
|
|||||||
})
|
})
|
||||||
return execStreamingResponse.finalPromise
|
return execStreamingResponse.finalPromise
|
||||||
})
|
})
|
||||||
|
it('should create a Smartshell instance', function () {
|
||||||
|
testSmartshell = new smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
sourceFilePaths: []
|
||||||
|
})
|
||||||
|
expect(testSmartshell).to.be.instanceof(smartshell.Smartshell)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from './smartshell.wrap'
|
export * from './smartshell.wrap'
|
||||||
|
export * from './smartshell.classes.smartshell'
|
||||||
|
@ -10,20 +10,47 @@ export interface ISmartshellContructorOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Smartshell {
|
export class Smartshell {
|
||||||
sourceFiles: string[] = []
|
executor: TExecutor
|
||||||
|
sourceFileArray: string[] = []
|
||||||
constructor (optionsArg: ISmartshellContructorOptions) {
|
constructor (optionsArg: ISmartshellContructorOptions) {
|
||||||
|
this.executor = optionsArg.executor
|
||||||
for (let sourceFilePath of optionsArg.sourceFilePaths) {
|
for (let sourceFilePath of optionsArg.sourceFilePaths) {
|
||||||
this.sourceFiles.push(sourceFilePath)
|
this.sourceFileArray.push(sourceFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSourceFiles(sourceFilePathsArray: string[]) {
|
addSourceFiles(sourceFilePathsArray: string[]) {
|
||||||
for(let sourceFilePath of sourceFilePathsArray) {
|
for(let sourceFilePath of sourceFilePathsArray) {
|
||||||
this.sourceFiles.push(sourceFilePath)
|
this.sourceFileArray.push(sourceFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanSourceFiles () {
|
cleanSourceFiles () {
|
||||||
this.sourceFiles = []
|
this.sourceFileArray = []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* executes silently and returns IExecResult
|
||||||
|
* @param commandArg
|
||||||
|
*/
|
||||||
|
execSilent(commandArg: string) {
|
||||||
|
let execCommand = this.createExecString(commandArg)
|
||||||
|
return smartshellWrap.execSilent(commandArg)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates the final sourcing string
|
||||||
|
* @param commandArg
|
||||||
|
*/
|
||||||
|
private createExecString (commandArg): string {
|
||||||
|
if (this.executor === 'bash') {
|
||||||
|
let sourceString = ''
|
||||||
|
for (let sourceFilePath of this.sourceFileArray) {
|
||||||
|
sourceString = sourceString + `source ${sourceFilePath} && `
|
||||||
|
}
|
||||||
|
return `bash -c '${sourceString} ${commandArg}'`
|
||||||
|
} else {
|
||||||
|
return commandArg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user