implement execSilent and execStrict
This commit is contained in:
parent
01e6411c29
commit
0f2d68cf5f
6
dist/smartshell.wrap.d.ts
vendored
6
dist/smartshell.wrap.d.ts
vendored
@ -18,12 +18,16 @@ export interface IExecResultStreaming {
|
||||
* executes a given command async
|
||||
* @param commandStringArg
|
||||
*/
|
||||
export declare let exec: (commandStringArg: string) => Promise<IExecResult>;
|
||||
export declare let exec: (commandStringArg: string, silentArg?: boolean, strictArg?: boolean) => Promise<IExecResult>;
|
||||
/**
|
||||
* executes a given command async and silent
|
||||
* @param commandStringArg
|
||||
*/
|
||||
export declare let execSilent: (commandStringArg: string) => Promise<IExecResult>;
|
||||
/**
|
||||
* executes strict, meaning it rejects the promise if something happens
|
||||
*/
|
||||
export declare let execStrict: (commandStringArg: string) => Promise<IExecResult>;
|
||||
/**
|
||||
* executes a command and allws you to stream output
|
||||
*/
|
||||
|
45
dist/smartshell.wrap.js
vendored
45
dist/smartshell.wrap.js
vendored
@ -1,4 +1,12 @@
|
||||
"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 plugins = require("./smartshell.plugins");
|
||||
/**
|
||||
@ -18,13 +26,15 @@ let importPath = (stringArg) => {
|
||||
* executes a given command async
|
||||
* @param commandStringArg
|
||||
*/
|
||||
exports.exec = (commandStringArg) => {
|
||||
exports.exec = (commandStringArg, silentArg = false, strictArg = false) => {
|
||||
let done = plugins.smartq.defer();
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true }, (code, stdout, stderr) => {
|
||||
if (stderr) {
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true, silent: silentArg }, (code, stdout, stderr) => {
|
||||
if (stderr && (stderr !== '') && (!silentArg || strictArg)) {
|
||||
console.log('StdErr found:');
|
||||
console.log(stderr);
|
||||
done.reject(stderr);
|
||||
}
|
||||
if (strictArg) {
|
||||
done.reject(new Error(stderr));
|
||||
return;
|
||||
}
|
||||
done.resolve({
|
||||
@ -38,22 +48,15 @@ exports.exec = (commandStringArg) => {
|
||||
* executes a given command async and silent
|
||||
* @param commandStringArg
|
||||
*/
|
||||
exports.execSilent = (commandStringArg) => {
|
||||
let done = plugins.smartq.defer();
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true, silent: true }, (code, stdout, stderr) => {
|
||||
if (stderr && stderr !== '') {
|
||||
console.log('StdErr found:');
|
||||
console.log(stderr);
|
||||
done.reject(stderr);
|
||||
return;
|
||||
}
|
||||
done.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
});
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
exports.execSilent = (commandStringArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield exports.exec(commandStringArg, true);
|
||||
});
|
||||
/**
|
||||
* executes strict, meaning it rejects the promise if something happens
|
||||
*/
|
||||
exports.execStrict = (commandStringArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield exports.exec(commandStringArg, true, true);
|
||||
});
|
||||
/**
|
||||
* executes a command and allws you to stream output
|
||||
*/
|
||||
@ -104,4 +107,4 @@ exports.which = (cmd) => {
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC53cmFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC53cmFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsZ0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xDQUFBO0FBRVUsUUFBQSx3QkFBd0IsR0FBRyxDQUFDLGdCQUF3QixFQUFFLFFBQWdCO0lBQy9FLDBCQUFrQixDQUFDLGdCQUFnQixFQUFFLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQTtBQUN0RCxDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNRLFFBQUEsS0FBSyxHQUFHLENBQUMsR0FBVztJQUM3QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBVSxDQUFBO0lBQ3pDLE9BQU8sQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLENBQUMsR0FBRyxFQUFFLElBQVk7UUFDbkMsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztZQUNSLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUE7UUFDbEIsQ0FBQztRQUNELElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDcEIsQ0FBQyxDQUFDLENBQUE7SUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUEifQ==
|
@ -37,13 +37,15 @@ let importPath = (stringArg): string => {
|
||||
* executes a given command async
|
||||
* @param commandStringArg
|
||||
*/
|
||||
export let exec = (commandStringArg: string): Promise<IExecResult> => {
|
||||
export let exec = (commandStringArg: string, silentArg: boolean = false, strictArg = false): Promise<IExecResult> => {
|
||||
let done = plugins.smartq.defer<IExecResult>()
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true }, (code, stdout, stderr) => {
|
||||
if (stderr) {
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true, silent: silentArg }, (code, stdout, stderr) => {
|
||||
if (stderr && (stderr !== '') && (!silentArg || strictArg)) {
|
||||
console.log('StdErr found:')
|
||||
console.log(stderr)
|
||||
done.reject(stderr)
|
||||
}
|
||||
if (strictArg) {
|
||||
done.reject(new Error(stderr))
|
||||
return
|
||||
}
|
||||
done.resolve({
|
||||
@ -58,21 +60,15 @@ export let exec = (commandStringArg: string): Promise<IExecResult> => {
|
||||
* executes a given command async and silent
|
||||
* @param commandStringArg
|
||||
*/
|
||||
export let execSilent = (commandStringArg: string) => {
|
||||
let done = plugins.smartq.defer<IExecResult>()
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true, silent: true }, (code, stdout, stderr) => {
|
||||
if (stderr && stderr !== '') {
|
||||
console.log('StdErr found:')
|
||||
console.log(stderr)
|
||||
done.reject(stderr)
|
||||
return
|
||||
}
|
||||
done.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
})
|
||||
})
|
||||
return done.promise
|
||||
export let execSilent = async (commandStringArg: string): Promise<IExecResult> => {
|
||||
return await exec(commandStringArg, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* executes strict, meaning it rejects the promise if something happens
|
||||
*/
|
||||
export let execStrict = async (commandStringArg: string): Promise<IExecResult> => {
|
||||
return await exec(commandStringArg, true, true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user