|
1 |
| -/* eslint-env node*/ |
2 |
| - |
3 |
| -import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from "child_process"; |
4 |
| - |
5 |
| -export function unsafeFromNullable(msg) { |
6 |
| - return x => { |
7 |
| - if (x === null) throw new Error(msg); |
8 |
| - return x; |
9 |
| - }; |
10 |
| -} |
11 |
| - |
12 |
| -export const connectedImpl = (cp) => cp.connected; |
13 |
| -export const disconnectImpl = (cp) => cp.disconnect(); |
14 |
| -export const exitCodeImpl = (cp) => cp.exitCode; |
15 |
| -export const pidImpl = (cp) => cp.pid; |
16 |
| -export const killImpl = (cp) => cp.kill(); |
17 |
| -export const killStrImpl = (cp, str) => cp.kill(str); |
18 |
| -export const killedImpl = (cp) => cp.killed; |
19 |
| -export const signalCodeImpl = (cp) => cp.signalCode; |
20 |
| -export const spawnArgs = (cp) => cp.spawnArgs; |
21 |
| -export const spawnFile = (cp) => cp.spawnFile; |
22 |
| - |
23 |
| -export function spawnImpl(command) { |
24 |
| - return args => opts => () => spawn(command, args, opts); |
25 |
| -} |
26 |
| - |
27 |
| -export function execImpl(command) { |
28 |
| - return opts => callback => () => exec( |
29 |
| - command, |
30 |
| - opts, |
31 |
| - (err, stdout, stderr) => { |
32 |
| - callback(err)(stdout)(stderr)(); |
33 |
| - } |
34 |
| - ); |
35 |
| -} |
36 |
| - |
37 |
| -export const execFileImpl = function execImpl(command) { |
38 |
| - return args => opts => callback => () => execFile( |
39 |
| - command, |
40 |
| - args, |
41 |
| - opts, |
42 |
| - (err, stdout, stderr) => { |
43 |
| - callback(err)(stdout)(stderr)(); |
44 |
| - } |
45 |
| - ); |
46 |
| -}; |
47 |
| - |
48 |
| -export function execSyncImpl(command) { |
49 |
| - return opts => () => execSync(command, opts); |
50 |
| -} |
51 |
| - |
52 |
| -export function execFileSyncImpl(command) { |
53 |
| - return args => opts => () => execFileSync(command, args, opts); |
54 |
| -} |
55 |
| - |
56 |
| -export function fork(cmd) { |
57 |
| - return args => () => cp_fork(cmd, args); |
58 |
| -} |
59 |
| - |
60 | 1 | const _undefined = undefined;
|
61 | 2 | export { _undefined as undefined };
|
62 |
| -import process from "process"; |
63 |
| -export { process }; |
0 commit comments