serverless-spy 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.jsii +3 -3
  2. package/dist/releasetag.txt +1 -1
  3. package/lib/src/ServerlessSpy.js +1 -1
  4. package/node_modules/bundle-name/index.js +2 -2
  5. package/node_modules/bundle-name/package.json +6 -5
  6. package/node_modules/bundle-name/readme.md +2 -2
  7. package/node_modules/default-browser/index.d.ts +5 -4
  8. package/node_modules/default-browser/index.js +13 -11
  9. package/node_modules/default-browser/package.json +14 -12
  10. package/node_modules/default-browser/windows.js +11 -5
  11. package/node_modules/default-browser-id/index.js +8 -32
  12. package/node_modules/default-browser-id/package.json +5 -8
  13. package/node_modules/default-browser-id/readme.md +2 -2
  14. package/node_modules/open/index.js +10 -10
  15. package/node_modules/{is-wsl → open/node_modules/is-wsl}/index.d.ts +2 -2
  16. package/node_modules/open/node_modules/is-wsl/index.js +27 -0
  17. package/node_modules/{is-wsl → open/node_modules/is-wsl}/package.json +21 -9
  18. package/node_modules/open/node_modules/is-wsl/readme.md +21 -0
  19. package/node_modules/open/package.json +9 -8
  20. package/node_modules/open/xdg-open +338 -137
  21. package/node_modules/run-applescript/index.d.ts +28 -4
  22. package/node_modules/run-applescript/index.js +20 -7
  23. package/node_modules/run-applescript/package.json +10 -9
  24. package/node_modules/run-applescript/readme.md +44 -6
  25. package/package.json +2 -2
  26. package/node_modules/big-integer/BigInteger.d.ts +0 -2393
  27. package/node_modules/big-integer/BigInteger.js +0 -1453
  28. package/node_modules/big-integer/BigInteger.min.js +0 -1
  29. package/node_modules/big-integer/LICENSE +0 -24
  30. package/node_modules/big-integer/README.md +0 -589
  31. package/node_modules/big-integer/bower.json +0 -29
  32. package/node_modules/big-integer/package.json +0 -48
  33. package/node_modules/big-integer/tsconfig.json +0 -24
  34. package/node_modules/bplist-parser/README.md +0 -48
  35. package/node_modules/bplist-parser/bplistParser.js +0 -363
  36. package/node_modules/bplist-parser/package.json +0 -34
  37. package/node_modules/bplist-parser/test/airplay.bplist +0 -0
  38. package/node_modules/bplist-parser/test/iTunes-small.bplist +0 -0
  39. package/node_modules/bplist-parser/test/int64.bplist +0 -0
  40. package/node_modules/bplist-parser/test/int64.xml +0 -10
  41. package/node_modules/bplist-parser/test/parseTest.js +0 -104
  42. package/node_modules/bplist-parser/test/sample1.bplist +0 -0
  43. package/node_modules/bplist-parser/test/sample2.bplist +0 -0
  44. package/node_modules/bplist-parser/test/uid.bplist +0 -0
  45. package/node_modules/bplist-parser/test/utf16.bplist +0 -0
  46. package/node_modules/bplist-parser/test/utf16_chinese.plist +0 -0
  47. package/node_modules/cross-spawn/CHANGELOG.md +0 -130
  48. package/node_modules/cross-spawn/LICENSE +0 -21
  49. package/node_modules/cross-spawn/README.md +0 -96
  50. package/node_modules/cross-spawn/index.js +0 -39
  51. package/node_modules/cross-spawn/lib/enoent.js +0 -59
  52. package/node_modules/cross-spawn/lib/parse.js +0 -91
  53. package/node_modules/cross-spawn/lib/util/escape.js +0 -45
  54. package/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  55. package/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  56. package/node_modules/cross-spawn/package.json +0 -73
  57. package/node_modules/default-browser/node_modules/execa/index.d.ts +0 -937
  58. package/node_modules/default-browser/node_modules/execa/index.js +0 -309
  59. package/node_modules/default-browser/node_modules/execa/lib/command.js +0 -120
  60. package/node_modules/default-browser/node_modules/execa/lib/error.js +0 -87
  61. package/node_modules/default-browser/node_modules/execa/lib/kill.js +0 -102
  62. package/node_modules/default-browser/node_modules/execa/lib/pipe.js +0 -42
  63. package/node_modules/default-browser/node_modules/execa/lib/promise.js +0 -36
  64. package/node_modules/default-browser/node_modules/execa/lib/stdio.js +0 -49
  65. package/node_modules/default-browser/node_modules/execa/lib/stream.js +0 -119
  66. package/node_modules/default-browser/node_modules/execa/lib/verbose.js +0 -19
  67. package/node_modules/default-browser/node_modules/execa/package.json +0 -87
  68. package/node_modules/default-browser/node_modules/execa/readme.md +0 -824
  69. package/node_modules/default-browser/node_modules/human-signals/LICENSE +0 -201
  70. package/node_modules/default-browser/node_modules/human-signals/README.md +0 -178
  71. package/node_modules/default-browser/node_modules/human-signals/build/src/core.js +0 -273
  72. package/node_modules/default-browser/node_modules/human-signals/build/src/main.d.ts +0 -73
  73. package/node_modules/default-browser/node_modules/human-signals/build/src/main.js +0 -70
  74. package/node_modules/default-browser/node_modules/human-signals/build/src/realtime.js +0 -16
  75. package/node_modules/default-browser/node_modules/human-signals/build/src/signals.js +0 -34
  76. package/node_modules/default-browser/node_modules/human-signals/package.json +0 -61
  77. package/node_modules/default-browser/node_modules/is-stream/index.d.ts +0 -81
  78. package/node_modules/default-browser/node_modules/is-stream/index.js +0 -29
  79. package/node_modules/default-browser/node_modules/is-stream/license +0 -9
  80. package/node_modules/default-browser/node_modules/is-stream/package.json +0 -44
  81. package/node_modules/default-browser/node_modules/is-stream/readme.md +0 -60
  82. package/node_modules/default-browser/node_modules/mimic-fn/index.d.ts +0 -52
  83. package/node_modules/default-browser/node_modules/mimic-fn/index.js +0 -71
  84. package/node_modules/default-browser/node_modules/mimic-fn/license +0 -9
  85. package/node_modules/default-browser/node_modules/mimic-fn/package.json +0 -45
  86. package/node_modules/default-browser/node_modules/mimic-fn/readme.md +0 -90
  87. package/node_modules/default-browser/node_modules/npm-run-path/index.d.ts +0 -90
  88. package/node_modules/default-browser/node_modules/npm-run-path/index.js +0 -52
  89. package/node_modules/default-browser/node_modules/npm-run-path/license +0 -9
  90. package/node_modules/default-browser/node_modules/npm-run-path/package.json +0 -49
  91. package/node_modules/default-browser/node_modules/npm-run-path/readme.md +0 -104
  92. package/node_modules/default-browser/node_modules/onetime/index.d.ts +0 -59
  93. package/node_modules/default-browser/node_modules/onetime/index.js +0 -41
  94. package/node_modules/default-browser/node_modules/onetime/license +0 -9
  95. package/node_modules/default-browser/node_modules/onetime/package.json +0 -45
  96. package/node_modules/default-browser/node_modules/onetime/readme.md +0 -94
  97. package/node_modules/default-browser/node_modules/path-key/index.d.ts +0 -31
  98. package/node_modules/default-browser/node_modules/path-key/index.js +0 -12
  99. package/node_modules/default-browser/node_modules/path-key/license +0 -9
  100. package/node_modules/default-browser/node_modules/path-key/package.json +0 -41
  101. package/node_modules/default-browser/node_modules/path-key/readme.md +0 -57
  102. package/node_modules/default-browser/node_modules/strip-final-newline/index.js +0 -14
  103. package/node_modules/default-browser/node_modules/strip-final-newline/license +0 -9
  104. package/node_modules/default-browser/node_modules/strip-final-newline/package.json +0 -43
  105. package/node_modules/default-browser/node_modules/strip-final-newline/readme.md +0 -35
  106. package/node_modules/execa/index.d.ts +0 -564
  107. package/node_modules/execa/index.js +0 -268
  108. package/node_modules/execa/lib/command.js +0 -52
  109. package/node_modules/execa/lib/error.js +0 -88
  110. package/node_modules/execa/lib/kill.js +0 -115
  111. package/node_modules/execa/lib/promise.js +0 -46
  112. package/node_modules/execa/lib/stdio.js +0 -52
  113. package/node_modules/execa/lib/stream.js +0 -97
  114. package/node_modules/execa/license +0 -9
  115. package/node_modules/execa/package.json +0 -74
  116. package/node_modules/execa/readme.md +0 -663
  117. package/node_modules/get-stream/buffer-stream.js +0 -52
  118. package/node_modules/get-stream/index.d.ts +0 -105
  119. package/node_modules/get-stream/index.js +0 -61
  120. package/node_modules/get-stream/license +0 -9
  121. package/node_modules/get-stream/package.json +0 -47
  122. package/node_modules/get-stream/readme.md +0 -124
  123. package/node_modules/human-signals/CHANGELOG.md +0 -11
  124. package/node_modules/human-signals/LICENSE +0 -201
  125. package/node_modules/human-signals/README.md +0 -165
  126. package/node_modules/human-signals/build/src/core.js +0 -273
  127. package/node_modules/human-signals/build/src/core.js.map +0 -1
  128. package/node_modules/human-signals/build/src/main.d.ts +0 -52
  129. package/node_modules/human-signals/build/src/main.js +0 -71
  130. package/node_modules/human-signals/build/src/main.js.map +0 -1
  131. package/node_modules/human-signals/build/src/realtime.js +0 -19
  132. package/node_modules/human-signals/build/src/realtime.js.map +0 -1
  133. package/node_modules/human-signals/build/src/signals.js +0 -35
  134. package/node_modules/human-signals/build/src/signals.js.map +0 -1
  135. package/node_modules/human-signals/package.json +0 -64
  136. package/node_modules/is-stream/index.d.ts +0 -79
  137. package/node_modules/is-stream/index.js +0 -28
  138. package/node_modules/is-stream/license +0 -9
  139. package/node_modules/is-stream/package.json +0 -42
  140. package/node_modules/is-stream/readme.md +0 -60
  141. package/node_modules/is-wsl/index.js +0 -31
  142. package/node_modules/is-wsl/license +0 -9
  143. package/node_modules/is-wsl/node_modules/is-docker/cli.js +0 -5
  144. package/node_modules/is-wsl/node_modules/is-docker/index.d.ts +0 -15
  145. package/node_modules/is-wsl/node_modules/is-docker/index.js +0 -29
  146. package/node_modules/is-wsl/node_modules/is-docker/license +0 -9
  147. package/node_modules/is-wsl/node_modules/is-docker/package.json +0 -42
  148. package/node_modules/is-wsl/node_modules/is-docker/readme.md +0 -27
  149. package/node_modules/is-wsl/readme.md +0 -36
  150. package/node_modules/isexe/.npmignore +0 -2
  151. package/node_modules/isexe/LICENSE +0 -15
  152. package/node_modules/isexe/README.md +0 -51
  153. package/node_modules/isexe/index.js +0 -57
  154. package/node_modules/isexe/mode.js +0 -41
  155. package/node_modules/isexe/package.json +0 -31
  156. package/node_modules/isexe/test/basic.js +0 -221
  157. package/node_modules/isexe/windows.js +0 -42
  158. package/node_modules/merge-stream/LICENSE +0 -21
  159. package/node_modules/merge-stream/README.md +0 -78
  160. package/node_modules/merge-stream/index.js +0 -41
  161. package/node_modules/merge-stream/package.json +0 -19
  162. package/node_modules/mimic-fn/index.d.ts +0 -54
  163. package/node_modules/mimic-fn/index.js +0 -13
  164. package/node_modules/mimic-fn/license +0 -9
  165. package/node_modules/mimic-fn/package.json +0 -42
  166. package/node_modules/mimic-fn/readme.md +0 -69
  167. package/node_modules/npm-run-path/index.d.ts +0 -89
  168. package/node_modules/npm-run-path/index.js +0 -47
  169. package/node_modules/npm-run-path/license +0 -9
  170. package/node_modules/npm-run-path/package.json +0 -44
  171. package/node_modules/npm-run-path/readme.md +0 -115
  172. package/node_modules/onetime/index.d.ts +0 -64
  173. package/node_modules/onetime/index.js +0 -44
  174. package/node_modules/onetime/license +0 -9
  175. package/node_modules/onetime/package.json +0 -43
  176. package/node_modules/onetime/readme.md +0 -94
  177. package/node_modules/path-key/index.d.ts +0 -40
  178. package/node_modules/path-key/index.js +0 -16
  179. package/node_modules/path-key/license +0 -9
  180. package/node_modules/path-key/package.json +0 -39
  181. package/node_modules/path-key/readme.md +0 -61
  182. package/node_modules/shebang-command/index.js +0 -19
  183. package/node_modules/shebang-command/license +0 -9
  184. package/node_modules/shebang-command/package.json +0 -34
  185. package/node_modules/shebang-command/readme.md +0 -34
  186. package/node_modules/shebang-regex/index.d.ts +0 -22
  187. package/node_modules/shebang-regex/index.js +0 -2
  188. package/node_modules/shebang-regex/license +0 -9
  189. package/node_modules/shebang-regex/package.json +0 -35
  190. package/node_modules/shebang-regex/readme.md +0 -33
  191. package/node_modules/signal-exit/LICENSE.txt +0 -16
  192. package/node_modules/signal-exit/README.md +0 -39
  193. package/node_modules/signal-exit/index.js +0 -202
  194. package/node_modules/signal-exit/package.json +0 -38
  195. package/node_modules/signal-exit/signals.js +0 -53
  196. package/node_modules/strip-final-newline/index.js +0 -16
  197. package/node_modules/strip-final-newline/license +0 -9
  198. package/node_modules/strip-final-newline/package.json +0 -40
  199. package/node_modules/strip-final-newline/readme.md +0 -30
  200. package/node_modules/titleize/index.d.ts +0 -17
  201. package/node_modules/titleize/index.js +0 -7
  202. package/node_modules/titleize/license +0 -9
  203. package/node_modules/titleize/package.json +0 -42
  204. package/node_modules/titleize/readme.md +0 -25
  205. package/node_modules/untildify/index.d.ts +0 -14
  206. package/node_modules/untildify/index.js +0 -12
  207. package/node_modules/untildify/license +0 -9
  208. package/node_modules/untildify/package.json +0 -43
  209. package/node_modules/untildify/readme.md +0 -30
  210. package/node_modules/which/CHANGELOG.md +0 -166
  211. package/node_modules/which/LICENSE +0 -15
  212. package/node_modules/which/README.md +0 -54
  213. package/node_modules/which/bin/node-which +0 -52
  214. package/node_modules/which/package.json +0 -43
  215. package/node_modules/which/which.js +0 -125
  216. /package/node_modules/{default-browser/node_modules/execa → open/node_modules/is-wsl}/license +0 -0
@@ -1,268 +0,0 @@
1
- 'use strict';
2
- const path = require('path');
3
- const childProcess = require('child_process');
4
- const crossSpawn = require('cross-spawn');
5
- const stripFinalNewline = require('strip-final-newline');
6
- const npmRunPath = require('npm-run-path');
7
- const onetime = require('onetime');
8
- const makeError = require('./lib/error');
9
- const normalizeStdio = require('./lib/stdio');
10
- const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = require('./lib/kill');
11
- const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = require('./lib/stream');
12
- const {mergePromise, getSpawnedPromise} = require('./lib/promise');
13
- const {joinCommand, parseCommand, getEscapedCommand} = require('./lib/command');
14
-
15
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
16
-
17
- const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
18
- const env = extendEnv ? {...process.env, ...envOption} : envOption;
19
-
20
- if (preferLocal) {
21
- return npmRunPath.env({env, cwd: localDir, execPath});
22
- }
23
-
24
- return env;
25
- };
26
-
27
- const handleArguments = (file, args, options = {}) => {
28
- const parsed = crossSpawn._parse(file, args, options);
29
- file = parsed.command;
30
- args = parsed.args;
31
- options = parsed.options;
32
-
33
- options = {
34
- maxBuffer: DEFAULT_MAX_BUFFER,
35
- buffer: true,
36
- stripFinalNewline: true,
37
- extendEnv: true,
38
- preferLocal: false,
39
- localDir: options.cwd || process.cwd(),
40
- execPath: process.execPath,
41
- encoding: 'utf8',
42
- reject: true,
43
- cleanup: true,
44
- all: false,
45
- windowsHide: true,
46
- ...options
47
- };
48
-
49
- options.env = getEnv(options);
50
-
51
- options.stdio = normalizeStdio(options);
52
-
53
- if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
54
- // #116
55
- args.unshift('/q');
56
- }
57
-
58
- return {file, args, options, parsed};
59
- };
60
-
61
- const handleOutput = (options, value, error) => {
62
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
63
- // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
64
- return error === undefined ? undefined : '';
65
- }
66
-
67
- if (options.stripFinalNewline) {
68
- return stripFinalNewline(value);
69
- }
70
-
71
- return value;
72
- };
73
-
74
- const execa = (file, args, options) => {
75
- const parsed = handleArguments(file, args, options);
76
- const command = joinCommand(file, args);
77
- const escapedCommand = getEscapedCommand(file, args);
78
-
79
- validateTimeout(parsed.options);
80
-
81
- let spawned;
82
- try {
83
- spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
84
- } catch (error) {
85
- // Ensure the returned error is always both a promise and a child process
86
- const dummySpawned = new childProcess.ChildProcess();
87
- const errorPromise = Promise.reject(makeError({
88
- error,
89
- stdout: '',
90
- stderr: '',
91
- all: '',
92
- command,
93
- escapedCommand,
94
- parsed,
95
- timedOut: false,
96
- isCanceled: false,
97
- killed: false
98
- }));
99
- return mergePromise(dummySpawned, errorPromise);
100
- }
101
-
102
- const spawnedPromise = getSpawnedPromise(spawned);
103
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
104
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
105
-
106
- const context = {isCanceled: false};
107
-
108
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
109
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
110
-
111
- const handlePromise = async () => {
112
- const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
113
- const stdout = handleOutput(parsed.options, stdoutResult);
114
- const stderr = handleOutput(parsed.options, stderrResult);
115
- const all = handleOutput(parsed.options, allResult);
116
-
117
- if (error || exitCode !== 0 || signal !== null) {
118
- const returnedError = makeError({
119
- error,
120
- exitCode,
121
- signal,
122
- stdout,
123
- stderr,
124
- all,
125
- command,
126
- escapedCommand,
127
- parsed,
128
- timedOut,
129
- isCanceled: context.isCanceled,
130
- killed: spawned.killed
131
- });
132
-
133
- if (!parsed.options.reject) {
134
- return returnedError;
135
- }
136
-
137
- throw returnedError;
138
- }
139
-
140
- return {
141
- command,
142
- escapedCommand,
143
- exitCode: 0,
144
- stdout,
145
- stderr,
146
- all,
147
- failed: false,
148
- timedOut: false,
149
- isCanceled: false,
150
- killed: false
151
- };
152
- };
153
-
154
- const handlePromiseOnce = onetime(handlePromise);
155
-
156
- handleInput(spawned, parsed.options.input);
157
-
158
- spawned.all = makeAllStream(spawned, parsed.options);
159
-
160
- return mergePromise(spawned, handlePromiseOnce);
161
- };
162
-
163
- module.exports = execa;
164
-
165
- module.exports.sync = (file, args, options) => {
166
- const parsed = handleArguments(file, args, options);
167
- const command = joinCommand(file, args);
168
- const escapedCommand = getEscapedCommand(file, args);
169
-
170
- validateInputSync(parsed.options);
171
-
172
- let result;
173
- try {
174
- result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
175
- } catch (error) {
176
- throw makeError({
177
- error,
178
- stdout: '',
179
- stderr: '',
180
- all: '',
181
- command,
182
- escapedCommand,
183
- parsed,
184
- timedOut: false,
185
- isCanceled: false,
186
- killed: false
187
- });
188
- }
189
-
190
- const stdout = handleOutput(parsed.options, result.stdout, result.error);
191
- const stderr = handleOutput(parsed.options, result.stderr, result.error);
192
-
193
- if (result.error || result.status !== 0 || result.signal !== null) {
194
- const error = makeError({
195
- stdout,
196
- stderr,
197
- error: result.error,
198
- signal: result.signal,
199
- exitCode: result.status,
200
- command,
201
- escapedCommand,
202
- parsed,
203
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
204
- isCanceled: false,
205
- killed: result.signal !== null
206
- });
207
-
208
- if (!parsed.options.reject) {
209
- return error;
210
- }
211
-
212
- throw error;
213
- }
214
-
215
- return {
216
- command,
217
- escapedCommand,
218
- exitCode: 0,
219
- stdout,
220
- stderr,
221
- failed: false,
222
- timedOut: false,
223
- isCanceled: false,
224
- killed: false
225
- };
226
- };
227
-
228
- module.exports.command = (command, options) => {
229
- const [file, ...args] = parseCommand(command);
230
- return execa(file, args, options);
231
- };
232
-
233
- module.exports.commandSync = (command, options) => {
234
- const [file, ...args] = parseCommand(command);
235
- return execa.sync(file, args, options);
236
- };
237
-
238
- module.exports.node = (scriptPath, args, options = {}) => {
239
- if (args && !Array.isArray(args) && typeof args === 'object') {
240
- options = args;
241
- args = [];
242
- }
243
-
244
- const stdio = normalizeStdio.node(options);
245
- const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
246
-
247
- const {
248
- nodePath = process.execPath,
249
- nodeOptions = defaultExecArgv
250
- } = options;
251
-
252
- return execa(
253
- nodePath,
254
- [
255
- ...nodeOptions,
256
- scriptPath,
257
- ...(Array.isArray(args) ? args : [])
258
- ],
259
- {
260
- ...options,
261
- stdin: undefined,
262
- stdout: undefined,
263
- stderr: undefined,
264
- stdio,
265
- shell: false
266
- }
267
- );
268
- };
@@ -1,52 +0,0 @@
1
- 'use strict';
2
- const normalizeArgs = (file, args = []) => {
3
- if (!Array.isArray(args)) {
4
- return [file];
5
- }
6
-
7
- return [file, ...args];
8
- };
9
-
10
- const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
11
- const DOUBLE_QUOTES_REGEXP = /"/g;
12
-
13
- const escapeArg = arg => {
14
- if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
15
- return arg;
16
- }
17
-
18
- return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
19
- };
20
-
21
- const joinCommand = (file, args) => {
22
- return normalizeArgs(file, args).join(' ');
23
- };
24
-
25
- const getEscapedCommand = (file, args) => {
26
- return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
27
- };
28
-
29
- const SPACES_REGEXP = / +/g;
30
-
31
- // Handle `execa.command()`
32
- const parseCommand = command => {
33
- const tokens = [];
34
- for (const token of command.trim().split(SPACES_REGEXP)) {
35
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
36
- const previousToken = tokens[tokens.length - 1];
37
- if (previousToken && previousToken.endsWith('\\')) {
38
- // Merge previous token with current one
39
- tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
40
- } else {
41
- tokens.push(token);
42
- }
43
- }
44
-
45
- return tokens;
46
- };
47
-
48
- module.exports = {
49
- joinCommand,
50
- getEscapedCommand,
51
- parseCommand
52
- };
@@ -1,88 +0,0 @@
1
- 'use strict';
2
- const {signalsByName} = require('human-signals');
3
-
4
- const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
5
- if (timedOut) {
6
- return `timed out after ${timeout} milliseconds`;
7
- }
8
-
9
- if (isCanceled) {
10
- return 'was canceled';
11
- }
12
-
13
- if (errorCode !== undefined) {
14
- return `failed with ${errorCode}`;
15
- }
16
-
17
- if (signal !== undefined) {
18
- return `was killed with ${signal} (${signalDescription})`;
19
- }
20
-
21
- if (exitCode !== undefined) {
22
- return `failed with exit code ${exitCode}`;
23
- }
24
-
25
- return 'failed';
26
- };
27
-
28
- const makeError = ({
29
- stdout,
30
- stderr,
31
- all,
32
- error,
33
- signal,
34
- exitCode,
35
- command,
36
- escapedCommand,
37
- timedOut,
38
- isCanceled,
39
- killed,
40
- parsed: {options: {timeout}}
41
- }) => {
42
- // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
43
- // We normalize them to `undefined`
44
- exitCode = exitCode === null ? undefined : exitCode;
45
- signal = signal === null ? undefined : signal;
46
- const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
47
-
48
- const errorCode = error && error.code;
49
-
50
- const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
51
- const execaMessage = `Command ${prefix}: ${command}`;
52
- const isError = Object.prototype.toString.call(error) === '[object Error]';
53
- const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
54
- const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
55
-
56
- if (isError) {
57
- error.originalMessage = error.message;
58
- error.message = message;
59
- } else {
60
- error = new Error(message);
61
- }
62
-
63
- error.shortMessage = shortMessage;
64
- error.command = command;
65
- error.escapedCommand = escapedCommand;
66
- error.exitCode = exitCode;
67
- error.signal = signal;
68
- error.signalDescription = signalDescription;
69
- error.stdout = stdout;
70
- error.stderr = stderr;
71
-
72
- if (all !== undefined) {
73
- error.all = all;
74
- }
75
-
76
- if ('bufferedData' in error) {
77
- delete error.bufferedData;
78
- }
79
-
80
- error.failed = true;
81
- error.timedOut = Boolean(timedOut);
82
- error.isCanceled = isCanceled;
83
- error.killed = killed && !timedOut;
84
-
85
- return error;
86
- };
87
-
88
- module.exports = makeError;
@@ -1,115 +0,0 @@
1
- 'use strict';
2
- const os = require('os');
3
- const onExit = require('signal-exit');
4
-
5
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
6
-
7
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
8
- const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
9
- const killResult = kill(signal);
10
- setKillTimeout(kill, signal, options, killResult);
11
- return killResult;
12
- };
13
-
14
- const setKillTimeout = (kill, signal, options, killResult) => {
15
- if (!shouldForceKill(signal, options, killResult)) {
16
- return;
17
- }
18
-
19
- const timeout = getForceKillAfterTimeout(options);
20
- const t = setTimeout(() => {
21
- kill('SIGKILL');
22
- }, timeout);
23
-
24
- // Guarded because there's no `.unref()` when `execa` is used in the renderer
25
- // process in Electron. This cannot be tested since we don't run tests in
26
- // Electron.
27
- // istanbul ignore else
28
- if (t.unref) {
29
- t.unref();
30
- }
31
- };
32
-
33
- const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
34
- return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
35
- };
36
-
37
- const isSigterm = signal => {
38
- return signal === os.constants.signals.SIGTERM ||
39
- (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
40
- };
41
-
42
- const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
43
- if (forceKillAfterTimeout === true) {
44
- return DEFAULT_FORCE_KILL_TIMEOUT;
45
- }
46
-
47
- if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
48
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
49
- }
50
-
51
- return forceKillAfterTimeout;
52
- };
53
-
54
- // `childProcess.cancel()`
55
- const spawnedCancel = (spawned, context) => {
56
- const killResult = spawned.kill();
57
-
58
- if (killResult) {
59
- context.isCanceled = true;
60
- }
61
- };
62
-
63
- const timeoutKill = (spawned, signal, reject) => {
64
- spawned.kill(signal);
65
- reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
66
- };
67
-
68
- // `timeout` option handling
69
- const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
70
- if (timeout === 0 || timeout === undefined) {
71
- return spawnedPromise;
72
- }
73
-
74
- let timeoutId;
75
- const timeoutPromise = new Promise((resolve, reject) => {
76
- timeoutId = setTimeout(() => {
77
- timeoutKill(spawned, killSignal, reject);
78
- }, timeout);
79
- });
80
-
81
- const safeSpawnedPromise = spawnedPromise.finally(() => {
82
- clearTimeout(timeoutId);
83
- });
84
-
85
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
86
- };
87
-
88
- const validateTimeout = ({timeout}) => {
89
- if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
90
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
91
- }
92
- };
93
-
94
- // `cleanup` option handling
95
- const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
96
- if (!cleanup || detached) {
97
- return timedPromise;
98
- }
99
-
100
- const removeExitHandler = onExit(() => {
101
- spawned.kill();
102
- });
103
-
104
- return timedPromise.finally(() => {
105
- removeExitHandler();
106
- });
107
- };
108
-
109
- module.exports = {
110
- spawnedKill,
111
- spawnedCancel,
112
- setupTimeout,
113
- validateTimeout,
114
- setExitHandler
115
- };
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- const nativePromisePrototype = (async () => {})().constructor.prototype;
4
- const descriptors = ['then', 'catch', 'finally'].map(property => [
5
- property,
6
- Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
7
- ]);
8
-
9
- // The return value is a mixin of `childProcess` and `Promise`
10
- const mergePromise = (spawned, promise) => {
11
- for (const [property, descriptor] of descriptors) {
12
- // Starting the main `promise` is deferred to avoid consuming streams
13
- const value = typeof promise === 'function' ?
14
- (...args) => Reflect.apply(descriptor.value, promise(), args) :
15
- descriptor.value.bind(promise);
16
-
17
- Reflect.defineProperty(spawned, property, {...descriptor, value});
18
- }
19
-
20
- return spawned;
21
- };
22
-
23
- // Use promises instead of `child_process` events
24
- const getSpawnedPromise = spawned => {
25
- return new Promise((resolve, reject) => {
26
- spawned.on('exit', (exitCode, signal) => {
27
- resolve({exitCode, signal});
28
- });
29
-
30
- spawned.on('error', error => {
31
- reject(error);
32
- });
33
-
34
- if (spawned.stdin) {
35
- spawned.stdin.on('error', error => {
36
- reject(error);
37
- });
38
- }
39
- });
40
- };
41
-
42
- module.exports = {
43
- mergePromise,
44
- getSpawnedPromise
45
- };
46
-
@@ -1,52 +0,0 @@
1
- 'use strict';
2
- const aliases = ['stdin', 'stdout', 'stderr'];
3
-
4
- const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
5
-
6
- const normalizeStdio = options => {
7
- if (!options) {
8
- return;
9
- }
10
-
11
- const {stdio} = options;
12
-
13
- if (stdio === undefined) {
14
- return aliases.map(alias => options[alias]);
15
- }
16
-
17
- if (hasAlias(options)) {
18
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
19
- }
20
-
21
- if (typeof stdio === 'string') {
22
- return stdio;
23
- }
24
-
25
- if (!Array.isArray(stdio)) {
26
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
27
- }
28
-
29
- const length = Math.max(stdio.length, aliases.length);
30
- return Array.from({length}, (value, index) => stdio[index]);
31
- };
32
-
33
- module.exports = normalizeStdio;
34
-
35
- // `ipc` is pushed unless it is already present
36
- module.exports.node = options => {
37
- const stdio = normalizeStdio(options);
38
-
39
- if (stdio === 'ipc') {
40
- return 'ipc';
41
- }
42
-
43
- if (stdio === undefined || typeof stdio === 'string') {
44
- return [stdio, stdio, stdio, 'ipc'];
45
- }
46
-
47
- if (stdio.includes('ipc')) {
48
- return stdio;
49
- }
50
-
51
- return [...stdio, 'ipc'];
52
- };
@@ -1,97 +0,0 @@
1
- 'use strict';
2
- const isStream = require('is-stream');
3
- const getStream = require('get-stream');
4
- const mergeStream = require('merge-stream');
5
-
6
- // `input` option
7
- const handleInput = (spawned, input) => {
8
- // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
9
- // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
10
- if (input === undefined || spawned.stdin === undefined) {
11
- return;
12
- }
13
-
14
- if (isStream(input)) {
15
- input.pipe(spawned.stdin);
16
- } else {
17
- spawned.stdin.end(input);
18
- }
19
- };
20
-
21
- // `all` interleaves `stdout` and `stderr`
22
- const makeAllStream = (spawned, {all}) => {
23
- if (!all || (!spawned.stdout && !spawned.stderr)) {
24
- return;
25
- }
26
-
27
- const mixed = mergeStream();
28
-
29
- if (spawned.stdout) {
30
- mixed.add(spawned.stdout);
31
- }
32
-
33
- if (spawned.stderr) {
34
- mixed.add(spawned.stderr);
35
- }
36
-
37
- return mixed;
38
- };
39
-
40
- // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
41
- const getBufferedData = async (stream, streamPromise) => {
42
- if (!stream) {
43
- return;
44
- }
45
-
46
- stream.destroy();
47
-
48
- try {
49
- return await streamPromise;
50
- } catch (error) {
51
- return error.bufferedData;
52
- }
53
- };
54
-
55
- const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
56
- if (!stream || !buffer) {
57
- return;
58
- }
59
-
60
- if (encoding) {
61
- return getStream(stream, {encoding, maxBuffer});
62
- }
63
-
64
- return getStream.buffer(stream, {maxBuffer});
65
- };
66
-
67
- // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
68
- const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
69
- const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
70
- const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
71
- const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
72
-
73
- try {
74
- return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
75
- } catch (error) {
76
- return Promise.all([
77
- {error, signal: error.signal, timedOut: error.timedOut},
78
- getBufferedData(stdout, stdoutPromise),
79
- getBufferedData(stderr, stderrPromise),
80
- getBufferedData(all, allPromise)
81
- ]);
82
- }
83
- };
84
-
85
- const validateInputSync = ({input}) => {
86
- if (isStream(input)) {
87
- throw new TypeError('The `input` option cannot be a stream in sync mode');
88
- }
89
- };
90
-
91
- module.exports = {
92
- handleInput,
93
- makeAllStream,
94
- getSpawnedResult,
95
- validateInputSync
96
- };
97
-