|
1 | | -'use strict'; |
| 1 | +"use strict"; |
2 | 2 |
|
3 | 3 | /* eslint-env node*/ |
4 | 4 |
|
5 | | -exports.unsafeFromNullable = function unsafeFromNullable (msg) { |
6 | | - return function (x) { |
7 | | - if (x === null) throw new Error(msg); |
8 | | - return x; |
9 | | - }; |
10 | | -}; |
11 | | - |
12 | | -exports.spawnImpl = function spawnImpl (command) { |
13 | | - return function (args) { |
14 | | - return function (opts) { |
15 | | - return function () { |
16 | | - return require('child_process').spawn(command, args, opts); |
17 | | - }; |
18 | | - }; |
19 | | - }; |
| 5 | +exports.unsafeFromNullable = function unsafeFromNullable(msg) { |
| 6 | + return function (x) { |
| 7 | + if (x === null) throw new Error(msg); |
| 8 | + return x; |
| 9 | + }; |
20 | 10 | }; |
21 | 11 |
|
22 | | -exports.execImpl = function execImpl (command) { |
| 12 | +exports.spawnImpl = function spawnImpl(command) { |
| 13 | + return function (args) { |
23 | 14 | return function (opts) { |
24 | | - return function (callback) { |
25 | | - return function () { |
26 | | - return require('child_process').exec(command, opts, function (err, stdout, stderr) { |
27 | | - callback(err)(stdout)(stderr)(); |
28 | | - }); |
29 | | - }; |
30 | | - }; |
| 15 | + return function () { |
| 16 | + return require("child_process").spawn(command, args, opts); |
| 17 | + }; |
31 | 18 | }; |
| 19 | + }; |
32 | 20 | }; |
33 | 21 |
|
34 | | - |
35 | | -exports.execFileImpl = function execImpl (command) { |
36 | | - return function (args) { |
37 | | - return function (opts) { |
38 | | - return function (callback) { |
39 | | - return function () { |
40 | | - return require('child_process').execFile(command, args, opts, function (err, stdout, stderr) { |
41 | | - callback(err)(stdout)(stderr)(); |
42 | | - }); |
43 | | - }; |
44 | | - }; |
45 | | - }; |
| 22 | +exports.execImpl = function execImpl(command) { |
| 23 | + return function (opts) { |
| 24 | + return function (callback) { |
| 25 | + return function () { |
| 26 | + return require("child_process").exec( |
| 27 | + command, |
| 28 | + opts, |
| 29 | + function (err, stdout, stderr) { |
| 30 | + callback(err)(stdout)(stderr)(); |
| 31 | + } |
| 32 | + ); |
| 33 | + }; |
46 | 34 | }; |
| 35 | + }; |
47 | 36 | }; |
48 | 37 |
|
49 | | -exports.execSyncImpl = function execSyncImpl (command) { |
| 38 | +exports.execFileImpl = function execImpl(command) { |
| 39 | + return function (args) { |
50 | 40 | return function (opts) { |
| 41 | + return function (callback) { |
51 | 42 | return function () { |
52 | | - return require('child_process').execSync(command, opts); |
| 43 | + return require("child_process").execFile( |
| 44 | + command, |
| 45 | + args, |
| 46 | + opts, |
| 47 | + function (err, stdout, stderr) { |
| 48 | + callback(err)(stdout)(stderr)(); |
| 49 | + } |
| 50 | + ); |
53 | 51 | }; |
| 52 | + }; |
54 | 53 | }; |
| 54 | + }; |
55 | 55 | }; |
56 | 56 |
|
57 | | -exports.execFileSyncImpl = function execFileSyncImpl (command) { |
58 | | - return function (args) { |
59 | | - return function (opts) { |
60 | | - return function () { |
61 | | - return require('child_process').execFileSync(command, args, opts); |
62 | | - }; |
63 | | - }; |
| 57 | +exports.execSyncImpl = function execSyncImpl(command) { |
| 58 | + return function (opts) { |
| 59 | + return function () { |
| 60 | + return require("child_process").execSync(command, opts); |
64 | 61 | }; |
| 62 | + }; |
65 | 63 | }; |
66 | 64 |
|
67 | | -exports.fork = function fork (cmd) { |
68 | | - return function (args) { |
69 | | - return function () { |
70 | | - return require('child_process').fork(cmd, args); |
71 | | - }; |
| 65 | +exports.execFileSyncImpl = function execFileSyncImpl(command) { |
| 66 | + return function (args) { |
| 67 | + return function (opts) { |
| 68 | + return function () { |
| 69 | + return require("child_process").execFileSync(command, args, opts); |
| 70 | + }; |
72 | 71 | }; |
| 72 | + }; |
73 | 73 | }; |
74 | 74 |
|
75 | | -exports.mkOnExit = function mkOnExit (mkChildExit) { |
76 | | - return function onExit (cp) { |
77 | | - return function (cb) { |
78 | | - return function () { |
79 | | - cp.on('exit', function (code, signal) { |
80 | | - cb(mkChildExit(code)(signal))(); |
81 | | - }); |
82 | | - }; |
83 | | - }; |
| 75 | +exports.fork = function fork(cmd) { |
| 76 | + return function (args) { |
| 77 | + return function () { |
| 78 | + return require("child_process").fork(cmd, args); |
84 | 79 | }; |
| 80 | + }; |
85 | 81 | }; |
86 | 82 |
|
87 | | -exports.mkOnClose = function mkOnClose (mkChildExit) { |
88 | | - return function onClose (cp) { |
89 | | - return function (cb) { |
90 | | - return function () { |
91 | | - cp.on('close', function (code, signal) { |
92 | | - cb(mkChildExit(code)(signal))(); |
93 | | - }); |
94 | | - }; |
95 | | - }; |
| 83 | +exports.mkOnExit = function mkOnExit(mkChildExit) { |
| 84 | + return function onExit(cp) { |
| 85 | + return function (cb) { |
| 86 | + return function () { |
| 87 | + cp.on("exit", function (code, signal) { |
| 88 | + cb(mkChildExit(code)(signal))(); |
| 89 | + }); |
| 90 | + }; |
96 | 91 | }; |
| 92 | + }; |
97 | 93 | }; |
98 | 94 |
|
99 | | -exports.onDisconnect = function onDisconnect (cp) { |
| 95 | +exports.mkOnClose = function mkOnClose(mkChildExit) { |
| 96 | + return function onClose(cp) { |
100 | 97 | return function (cb) { |
101 | | - return function () { |
102 | | - cp.on('disconnect', cb); |
103 | | - }; |
| 98 | + return function () { |
| 99 | + cp.on("close", function (code, signal) { |
| 100 | + cb(mkChildExit(code)(signal))(); |
| 101 | + }); |
| 102 | + }; |
104 | 103 | }; |
| 104 | + }; |
105 | 105 | }; |
106 | 106 |
|
107 | | -exports.mkOnMessage = function mkOnMessage (nothing) { |
108 | | - return function (just) { |
109 | | - return function onMessage (cp) { |
110 | | - return function (cb) { |
111 | | - return function () { |
112 | | - cp.on('message', function (mess, sendHandle) { |
113 | | - cb(mess, sendHandle ? just(sendHandle) : nothing)(); |
114 | | - }); |
115 | | - }; |
116 | | - }; |
117 | | - }; |
| 107 | +exports.onDisconnect = function onDisconnect(cp) { |
| 108 | + return function (cb) { |
| 109 | + return function () { |
| 110 | + cp.on("disconnect", cb); |
118 | 111 | }; |
| 112 | + }; |
119 | 113 | }; |
120 | 114 |
|
121 | | -exports.onError = function onError (cp) { |
122 | | - return function (cb) { |
| 115 | +exports.mkOnMessage = function mkOnMessage(nothing) { |
| 116 | + return function (just) { |
| 117 | + return function onMessage(cp) { |
| 118 | + return function (cb) { |
123 | 119 | return function () { |
124 | | - cp.on('error', function (err) { |
125 | | - cb(err)(); |
126 | | - }); |
| 120 | + cp.on("message", function (mess, sendHandle) { |
| 121 | + cb(mess, sendHandle ? just(sendHandle) : nothing)(); |
| 122 | + }); |
127 | 123 | }; |
| 124 | + }; |
| 125 | + }; |
| 126 | + }; |
| 127 | +}; |
| 128 | + |
| 129 | +exports.onError = function onError(cp) { |
| 130 | + return function (cb) { |
| 131 | + return function () { |
| 132 | + cp.on("error", function (err) { |
| 133 | + cb(err)(); |
| 134 | + }); |
128 | 135 | }; |
| 136 | + }; |
129 | 137 | }; |
130 | 138 |
|
131 | 139 | exports.undefined = undefined; |
|
0 commit comments