smartshell/ts/smartshell.wrap.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

import * as plugins from "./smartshell.plugins";
import { ShellLog } from "./smartshell.classes.shelllog";
2017-03-08 15:51:02 +00:00
2017-03-10 19:14:40 +00:00
// interfaces
import * as cp from "child_process";
import { Deferred } from "@pushrocks/smartpromise";
2017-03-10 19:14:40 +00:00
2017-03-11 12:46:08 +00:00
/**
* interface for ExecResult
*/
2017-03-08 15:51:02 +00:00
export interface IExecResult {
exitCode: number;
stdout: string;
2017-03-08 15:51:02 +00:00
}
2017-03-11 12:46:08 +00:00
/**
* interface for streaming ExecResult
*/
2017-03-10 19:14:40 +00:00
export interface IExecResultStreaming {
childProcess: cp.ChildProcess;
finalPromise: Promise<IExecResult>;
2017-03-10 19:14:40 +00:00
}
2017-06-22 16:17:45 +00:00
2017-06-27 09:18:37 +00:00
2017-03-11 12:46:08 +00:00
/**
* get a path
*/
export let which = (cmd: string): Promise<string> => {
let done = plugins.smartpromise.defer<string>();
2017-03-11 12:46:08 +00:00
plugins.which(cmd, (err, path: string) => {
if (err) {
done.reject(err);
2017-03-11 12:46:08 +00:00
}
done.resolve(path);
});
return done.promise;
};
/* /////////////////////////////////////////////////////////
/**
* executes silently and returns IExecResult
* @param commandArg
async execSilent(commandArg: string) {
let execCommand = this..createExecString(commandArg);
return await smartshellWrap.execSilent(execCommand);
}
/**
* executes and returns IExecResult
* @param commandArg
async exec(commandArg: string) {
let execCommand = this.createExecString(commandArg);
return await smartshellWrap.exec(execCommand);
} */