update smartshell

This commit is contained in:
Philipp Kunz 2017-03-11 13:46:08 +01:00
parent e96f981573
commit 6ec8ce3545
8 changed files with 70 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import * as shelljs from 'shelljs'; import * as shelljs from 'shelljs';
import * as smartq from 'smartq'; import * as smartq from 'smartq';
export { shelljs, smartq }; import * as which from 'which';
export { shelljs, smartq, which };

View File

@ -4,4 +4,6 @@ const shelljs = require("shelljs");
exports.shelljs = shelljs; exports.shelljs = shelljs;
const smartq = require("smartq"); const smartq = require("smartq");
exports.smartq = smartq; exports.smartq = smartq;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbUNBQWtDO0FBSWhDLDBCQUFPO0FBSFQsaUNBQWdDO0FBSTlCLHdCQUFNIn0= const which = require("which");
exports.which = which;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbUNBQWtDO0FBS2hDLDBCQUFPO0FBSlQsaUNBQWdDO0FBSzlCLHdCQUFNO0FBSlIsK0JBQThCO0FBSzVCLHNCQUFLIn0=

View File

@ -1,9 +1,15 @@
/// <reference types="node" /> /// <reference types="node" />
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';
/**
* interface for ExecResult
*/
export interface IExecResult { export interface IExecResult {
exitCode: number; exitCode: number;
stdout: string; stdout: string;
} }
/**
* interface for streaming ExecResult
*/
export interface IExecResultStreaming { export interface IExecResultStreaming {
childProcess: ChildProcess; childProcess: ChildProcess;
finalPromise: Promise<IExecResult>; finalPromise: Promise<IExecResult>;
@ -25,3 +31,7 @@ export declare let execStreaming: (commandStringArg: string) => {
childProcess: ChildProcess; childProcess: ChildProcess;
finalPromise: Promise<IExecResult>; finalPromise: Promise<IExecResult>;
}; };
/**
* get a path
*/
export declare let which: (cmd: string) => Promise<string>;

View File

@ -45,4 +45,17 @@ exports.execStreaming = (commandStringArg) => {
finalPromise: childProcessEnded.promise finalPromise: childProcessEnded.promise
}; };
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC53cmFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC53cmFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsZ0RBQStDO0FBZ0IvQzs7O0dBR0c7QUFDUSxRQUFBLElBQUksR0FBRyxDQUFDLGdCQUF3QjtJQUN6QyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBZSxDQUFBO0lBQzlDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGdCQUFnQixFQUFFLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxNQUFNO1FBQzNFLElBQUksQ0FBQyxPQUFPLENBQUM7WUFDWCxRQUFRLEVBQUUsSUFBSTtZQUNkLE1BQU0sRUFBRSxNQUFNO1NBQ2YsQ0FBQyxDQUFBO0lBQ0osQ0FBQyxDQUFDLENBQUE7SUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUE7QUFFRDs7O0dBR0c7QUFDUSxRQUFBLFVBQVUsR0FBRyxDQUFDLGdCQUF3QjtJQUMvQyxJQUFJLElBQUksR0FB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(cmd) => {
let done = plugins.smartq.defer();
plugins.which(cmd, (err, path) => {
if (err) {
done.reject(err);
}
done.resolve(path);
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzaGVsbC53cmFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzaGVsbC53cmFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsZ0RBQStDO0FBc0IvQzs7O0dBR0c7QUFDUSxRQUFBLElBQUksR0FBRyxDQUFDLGdCQUF3QjtJQUN6QyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBZSxDQUFBO0lBQzlDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGdCQUFnQixFQUFFLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxNQUFNO1FBQzNFLElBQUksQ0FBQyxPQUFPLENBQUM7WUFDWCxRQUFRLEVBQUUsSUFBSTtZQUNkLE1BQU0sRUFBRSxNQUFNO1NBQ2YsQ0FBQyxDQUFBO0lBQ0osQ0FBQyxDQUFDLENBQUE7SUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUE7QUFFRDs7O0dBR0c7QUFDUSxRQUFBLFVBQVUsR0FBRyxDQUFDLGdCQUF3QjtJQUMvQyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBZSxDQUFBO0lBQzlDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGdCQUFnQixFQUFFLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLEVBQUUsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUF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yxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUM7WUFDUixJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ2xCLENBQUM7UUFDRCxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQ3BCLENBQUMsQ0FBQyxDQUFBO0lBQ0YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDckIsQ0FBQyxDQUFBIn0=

View File

@ -27,7 +27,9 @@
}, },
"dependencies": { "dependencies": {
"@types/shelljs": "^0.6.0", "@types/shelljs": "^0.6.0",
"@types/which": "^1.0.28",
"shelljs": "^0.7.6", "shelljs": "^0.7.6",
"smartq": "^1.1.0" "smartq": "^1.1.0",
"which": "^1.2.12"
} }
} }

View File

@ -1,7 +1,9 @@
import * as shelljs from 'shelljs' import * as shelljs from 'shelljs'
import * as smartq from 'smartq' import * as smartq from 'smartq'
import * as which from 'which'
export { export {
shelljs, shelljs,
smartq smartq,
which
} }

View File

@ -4,11 +4,17 @@ import * as plugins from './smartshell.plugins'
import { ChildProcess } from 'child_process' import { ChildProcess } from 'child_process'
import { Deferred } from 'smartq' import { Deferred } from 'smartq'
/**
* interface for ExecResult
*/
export interface IExecResult { export interface IExecResult {
exitCode: number, exitCode: number,
stdout: string stdout: string
} }
/**
* interface for streaming ExecResult
*/
export interface IExecResultStreaming { export interface IExecResultStreaming {
childProcess: ChildProcess, childProcess: ChildProcess,
finalPromise: Promise<IExecResult> finalPromise: Promise<IExecResult>
@ -60,3 +66,17 @@ export let execStreaming = (commandStringArg: string) => {
finalPromise: childProcessEnded.promise finalPromise: childProcessEnded.promise
} }
} }
/**
* get a path
*/
export let which = (cmd: string): Promise<string> => {
let done = plugins.smartq.defer()
plugins.which(cmd, (err, path: string) => {
if (err) {
done.reject(err)
}
done.resolve(path)
})
return done.promise
}

View File

@ -37,6 +37,10 @@
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
"@types/which@^1.0.28":
version "1.0.28"
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6"
assertion-error@^1.0.1: assertion-error@^1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
@ -114,6 +118,10 @@ interpret@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"
isexe@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0"
minimatch@^3.0.2: minimatch@^3.0.2:
version "3.0.3" version "3.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
@ -202,6 +210,12 @@ typings-test@^1.0.3:
"@types/mocha" "^2.2.31" "@types/mocha" "^2.2.31"
typings-global "*" typings-global "*"
which@^1.2.12:
version "1.2.12"
resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192"
dependencies:
isexe "^1.1.1"
wrappy@1: wrappy@1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"