now working in child processes
This commit is contained in:
parent
a745a435db
commit
ced0ce7b53
33
dist/smartshell.wrap.js
vendored
33
dist/smartshell.wrap.js
vendored
@ -1,13 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./smartshell.plugins");
|
||||
/**
|
||||
* import path
|
||||
*/
|
||||
let importPath = (stringArg) => {
|
||||
if (process.env.SMARTSHELL_PATH) {
|
||||
let commandResult = `PATH=${process.env.SMARTSHELL_PATH} && ${stringArg}`;
|
||||
// console.log(commandResult)
|
||||
return commandResult;
|
||||
}
|
||||
else {
|
||||
return stringArg;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* executes a given command async
|
||||
* @param commandStringArg
|
||||
*/
|
||||
exports.exec = (commandStringArg) => {
|
||||
let done = plugins.smartq.defer();
|
||||
plugins.shelljs.exec(commandStringArg, { async: true }, (code, stdout, stderr) => {
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true }, (code, stdout, stderr) => {
|
||||
if (stderr) {
|
||||
console.log('StdErr found:');
|
||||
console.log(stderr);
|
||||
done.reject(stderr);
|
||||
return;
|
||||
}
|
||||
done.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
@ -21,7 +40,13 @@ exports.exec = (commandStringArg) => {
|
||||
*/
|
||||
exports.execSilent = (commandStringArg) => {
|
||||
let done = plugins.smartq.defer();
|
||||
plugins.shelljs.exec(commandStringArg, { async: true, silent: true }, (code, stdout, stderr) => {
|
||||
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
|
||||
@ -34,7 +59,7 @@ exports.execSilent = (commandStringArg) => {
|
||||
*/
|
||||
exports.execStreaming = (commandStringArg, silentArg = false) => {
|
||||
let childProcessEnded = plugins.smartq.defer();
|
||||
let execChildProcess = plugins.shelljs.exec(commandStringArg, { async: true, silent: silentArg }, (code, stdout, stderr) => {
|
||||
let execChildProcess = plugins.shelljs.exec(importPath(commandStringArg), { async: true, silent: silentArg }, (code, stdout, stderr) => {
|
||||
childProcessEnded.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
@ -79,4 +104,4 @@ exports.which = (cmd) => {
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC53cmFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC53cmFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsZ0RBQStDO0FBc0IvQzs7O0dBR0c7QUFDUSxRQUFBLElBQUksR0FBRyxDQUFDLGdCQUF3QjtJQUN6QyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBZSxDQUFBO0lBQzlDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGdCQUFnQixFQUFFLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxNQUFNO1FBQzNFLElBQUksQ0FBQyxPQUFPLENBQUM7WUFDWCxRQUFRLEVBQUUsSUFBSTtZQUNkLE1BQU0sRUFBRSxNQUFNO1NBQ2YsQ0FBQyxDQUFBO0lBQ0osQ0FBQyxDQUFDLENBQUE7SUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUE7QUFFRDs7O0dBR0c7QUFDUSxRQUFBLFVBQVUsR0FBRyxDQUFDLGdCQUF3QjtJQUMvQyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQ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UUsSUFBWTtRQUNuQyxFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1lBQ1IsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQTtRQUNsQixDQUFDO1FBQ0QsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUNwQixDQUFDLENBQUMsQ0FBQTtJQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3JCLENBQUMsQ0FBQSJ9
|
@ -5,7 +5,8 @@
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
|
||||
"test": "(npmts)",
|
||||
"testLocal": "(ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -20,13 +20,32 @@ export interface IExecResultStreaming {
|
||||
finalPromise: Promise<IExecResult>
|
||||
}
|
||||
|
||||
/**
|
||||
* import path
|
||||
*/
|
||||
let importPath = (stringArg): string => {
|
||||
if (process.env.SMARTSHELL_PATH) {
|
||||
let commandResult = `PATH=${process.env.SMARTSHELL_PATH} && ${stringArg}`
|
||||
// console.log(commandResult)
|
||||
return commandResult
|
||||
} else {
|
||||
return stringArg
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* executes a given command async
|
||||
* @param commandStringArg
|
||||
*/
|
||||
export let exec = (commandStringArg: string): Promise<IExecResult> => {
|
||||
let done = plugins.smartq.defer<IExecResult>()
|
||||
plugins.shelljs.exec(commandStringArg, { async: true }, (code, stdout, stderr) => {
|
||||
plugins.shelljs.exec(importPath(commandStringArg), { async: true }, (code, stdout, stderr) => {
|
||||
if (stderr) {
|
||||
console.log('StdErr found:')
|
||||
console.log(stderr)
|
||||
done.reject(stderr)
|
||||
return
|
||||
}
|
||||
done.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
@ -41,7 +60,13 @@ export let exec = (commandStringArg: string): Promise<IExecResult> => {
|
||||
*/
|
||||
export let execSilent = (commandStringArg: string) => {
|
||||
let done = plugins.smartq.defer<IExecResult>()
|
||||
plugins.shelljs.exec(commandStringArg, { async: true, silent: true }, (code, stdout, stderr) => {
|
||||
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
|
||||
@ -55,7 +80,7 @@ export let execSilent = (commandStringArg: string) => {
|
||||
*/
|
||||
export let execStreaming = (commandStringArg: string, silentArg: boolean = false) => {
|
||||
let childProcessEnded = plugins.smartq.defer<IExecResult>()
|
||||
let execChildProcess = plugins.shelljs.exec(commandStringArg, {async: true, silent: silentArg}, (code, stdout, stderr) => {
|
||||
let execChildProcess = plugins.shelljs.exec(importPath(commandStringArg), {async: true, silent: silentArg}, (code, stdout, stderr) => {
|
||||
childProcessEnded.resolve({
|
||||
exitCode: code,
|
||||
stdout: stdout
|
||||
|
Loading…
Reference in New Issue
Block a user