update smartshell
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
import * as shelljs from 'shelljs'
|
||||
import * as smartq from 'smartq'
|
||||
import * as which from 'which'
|
||||
|
||||
export {
|
||||
shelljs,
|
||||
smartq
|
||||
}
|
||||
smartq,
|
||||
which
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user