improve tests

This commit is contained in:
Philipp Kunz 2017-03-11 01:58:09 +01:00
parent 4130ab55e2
commit d849c17817
4 changed files with 36 additions and 7 deletions

View File

@ -1,4 +1,12 @@
"use strict"; "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 }); Object.defineProperty(exports, "__esModule", { value: true });
const smartshellWrap = require("./smartshell.wrap"); const smartshellWrap = require("./smartshell.wrap");
class Smartshell { class Smartshell {
@ -22,8 +30,10 @@ class Smartshell {
* @param commandArg * @param commandArg
*/ */
execSilent(commandArg) { execSilent(commandArg) {
return __awaiter(this, void 0, void 0, function* () {
let execCommand = this.createExecString(commandArg); let execCommand = this.createExecString(commandArg);
return smartshellWrap.execSilent(commandArg); return yield smartshellWrap.execSilent(commandArg);
});
} }
/** /**
* creates the final sourcing string * creates the final sourcing string
@ -43,4 +53,4 @@ class Smartshell {
} }
} }
exports.Smartshell = Smartshell; exports.Smartshell = Smartshell;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5jbGFzc2VzLnNtYXJ0c2hlbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNoZWxsLmNsYXNzZXMuc21hcnRzaGVsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLG9EQUFtRDtBQVVuRDtJQUdFLFlBQWEsVUFBd0M7UUFEckQsb0JBQWUsR0FBYSxFQUFFLENBQUE7UUFFNUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxVQUFVLENBQ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0I7O1lBQ2xDLElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsQ0FBQTtZQUNuRCxNQUFNLENBQUMsTUFBTSxjQUFjLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ3BELENBQUM7S0FBQTtJQUVEOzs7T0FHRztJQUNLLGdCQUFnQixDQUFFLFVBQVU7UUFDbEMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsS0FBSyxNQUFNLENBQUMsQ0FBQyxDQUFDO1lBQzdCLElBQUksWUFBWSxHQUFHLEVBQUUsQ0FBQTtZQUNyQixHQUFHLENBQUMsQ0FBQyxJQUFJLGNBQWMsSUFBSSxJQUFJLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQztnQkFDaEQsWUFBWSxHQUFHLFlBQVksR0FBRyxVQUFVLGNBQWMsTUFBTSxDQUFBO1lBQzlELENBQUM7WUFDRCxNQUFNLENBQUMsWUFBWSxZQUFZLElBQUksVUFBVSxHQUFHLENBQUE7UUFDbEQsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ04sTUFBTSxDQUFDLFVBQVUsQ0FBQTtRQUNuQixDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBNUNELGdDQTRDQyJ9

View File

@ -1,4 +1,12 @@
"use strict"; "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 }); Object.defineProperty(exports, "__esModule", { value: true });
require("typings-test"); require("typings-test");
const smartchai_1 = require("smartchai"); const smartchai_1 = require("smartchai");
@ -30,5 +38,10 @@ describe('smartshell', function () {
}); });
smartchai_1.expect(testSmartshell).to.be.instanceof(smartshell.Smartshell); smartchai_1.expect(testSmartshell).to.be.instanceof(smartshell.Smartshell);
}); });
it('should run async', function () {
return testSmartshell.execSilent('sleep 1 && npm -v').then((execResult) => __awaiter(this, void 0, void 0, function* () {
console.log(execResult.stdout);
}));
});
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3QkFBcUI7QUFDckIseUNBQWtDO0FBRWxDLDRDQUEyQztBQUUzQyxJQUFJLGNBQXFDLENBQUE7QUFFekMsUUFBUSxDQUFDLFlBQVksRUFBRTtJQUNyQixFQUFFLENBQUMscUJBQXFCLEVBQUU7UUFDeEIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtRQUNyQixNQUFNLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxVQUFVO1lBQy9DLGtCQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsVUFBVSxDQUFDLENBQUE7UUFDaEQsQ0FBQyxDQUFDLENBQUE7SUFDSixDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyw2QkFBNkIsRUFBRTtRQUNoQyxNQUFNLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxVQUFVO1lBQ3JELGtCQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsVUFBVSxDQUFDLENBQUE7U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sQ0FBQyxxQ0FBcUMsRUFBRTtRQUN4QyxjQUFjLEdBQUcsSUFBSSxVQUFVLENBQUMsVUFBVSxDQUFDO1lBQ3pDLFFBQVEsRUFBRSxNQUFNO1lBQ2hCLGVBQWUsRUFBRSxFQUFFO1NBQ3BCLENBQUMsQ0FBQTtRQUNGLGtCQUFNLENBQUMsY0FBYyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO0lBQ2hFLENBQUMsQ0FBQyxDQUFBO0lBRUYsRUFBRSxDQUFDLGtCQUFrQixFQUFFO1FBQ3JCLE1BQU0sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLG1CQUFtQixDQUFDLENBQUMsSUFBSSxDQUFDLENBQU8sVUFBVTtZQUMxRSxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUNoQyxDQUFDLENBQUEsQ0FBQyxDQUFBO0lBQ0osQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -31,4 +31,10 @@ describe('smartshell', function () {
}) })
expect(testSmartshell).to.be.instanceof(smartshell.Smartshell) expect(testSmartshell).to.be.instanceof(smartshell.Smartshell)
}) })
it('should run async', function () {
return testSmartshell.execSilent('sleep 1 && npm -v').then(async (execResult) => {
console.log(execResult.stdout)
})
})
}) })

View File

@ -33,9 +33,9 @@ export class Smartshell {
* executes silently and returns IExecResult * executes silently and returns IExecResult
* @param commandArg * @param commandArg
*/ */
execSilent(commandArg: string) { async execSilent (commandArg: string) {
let execCommand = this.createExecString(commandArg) let execCommand = this.createExecString(commandArg)
return smartshellWrap.execSilent(commandArg) return await smartshellWrap.execSilent(commandArg)
} }
/** /**