update smartshell

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

View File

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

View File

@ -4,11 +4,17 @@ import * as plugins from './smartshell.plugins'
import { ChildProcess } from 'child_process'
import { Deferred } from 'smartq'
/**
* interface for ExecResult
*/
export interface IExecResult {
exitCode: number,
stdout: string
}
/**
* interface for streaming ExecResult
*/
export interface IExecResultStreaming {
childProcess: ChildProcess,
finalPromise: Promise<IExecResult>
@ -60,3 +66,17 @@ export let execStreaming = (commandStringArg: string) => {
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
}