-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathchild-process.ts
More file actions
57 lines (50 loc) · 1.02 KB
/
child-process.ts
File metadata and controls
57 lines (50 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { exec as _exec } from "child_process";
import type { ExecOptions } from "child_process";
import { returnFalse } from ".";
export interface IExecResult {
stdout: string;
stderr: string;
}
export function exec(
command: string,
options?: ExecOptions
): Promise<IExecResult> {
return new Promise((resolve, reject) => {
_exec(command, options, (err, stdout, stderr) => {
if (err) {
return reject(err);
}
resolve({
stdout,
stderr,
});
});
});
}
export function execSafe(
command: string,
options?: ExecOptions
): Promise<IExecResult | false> {
return exec(command, options).catch(returnFalse);
}
/*
export class ChildProcess {
public exec(
command: string,
options?: childProcess.ExecOptions
): Promise<IProcessInfo> {
return new Promise<IProcessInfo>((resolve, reject) => {
childProcess.exec(command, options, (err, stdout, stderr) => {
if (err) {
reject(err);
}
const result: IProcessInfo = {
stdout,
stderr,
};
resolve(result);
});
});
}
}
*/