This commit is contained in:
2017-06-22 18:17:45 +02:00
parent 0e95e58215
commit c73e48450a
6 changed files with 210 additions and 90 deletions

View File

@ -67,6 +67,22 @@ export let execStreaming = (commandStringArg: string) => {
}
}
/**
* executes a command and returns promise that will be fullfilled once an putput line matches RegexArg
* @param commandStringArg
* @param regexArg
*/
export let execAndWaitForLine = (commandStringArg: string, regexArg: RegExp) => {
let done = plugins.smartq.defer()
let execStreamingResult = execStreaming(commandStringArg)
execStreamingResult.childProcess.on('data', (stdOutChunk: string) => {
if (regexArg.test(stdOutChunk)) {
done.resolve()
}
})
return done.promise
}
/**
* get a path
*/