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,309 +0,0 @@
1
- import {Buffer} from 'node:buffer';
2
- import path from 'node:path';
3
- import childProcess from 'node:child_process';
4
- import process from 'node:process';
5
- import crossSpawn from 'cross-spawn';
6
- import stripFinalNewline from 'strip-final-newline';
7
- import {npmRunPathEnv} from 'npm-run-path';
8
- import onetime from 'onetime';
9
- import {makeError} from './lib/error.js';
10
- import {normalizeStdio, normalizeStdioNode} from './lib/stdio.js';
11
- import {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} from './lib/kill.js';
12
- import {addPipeMethods} from './lib/pipe.js';
13
- import {handleInput, getSpawnedResult, makeAllStream, handleInputSync} from './lib/stream.js';
14
- import {mergePromise, getSpawnedPromise} from './lib/promise.js';
15
- import {joinCommand, parseCommand, parseTemplates, getEscapedCommand} from './lib/command.js';
16
- import {logCommand, verboseDefault} from './lib/verbose.js';
17
-
18
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
19
-
20
- const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
21
- const env = extendEnv ? {...process.env, ...envOption} : envOption;
22
-
23
- if (preferLocal) {
24
- return npmRunPathEnv({env, cwd: localDir, execPath});
25
- }
26
-
27
- return env;
28
- };
29
-
30
- const handleArguments = (file, args, options = {}) => {
31
- const parsed = crossSpawn._parse(file, args, options);
32
- file = parsed.command;
33
- args = parsed.args;
34
- options = parsed.options;
35
-
36
- options = {
37
- maxBuffer: DEFAULT_MAX_BUFFER,
38
- buffer: true,
39
- stripFinalNewline: true,
40
- extendEnv: true,
41
- preferLocal: false,
42
- localDir: options.cwd || process.cwd(),
43
- execPath: process.execPath,
44
- encoding: 'utf8',
45
- reject: true,
46
- cleanup: true,
47
- all: false,
48
- windowsHide: true,
49
- verbose: verboseDefault,
50
- ...options,
51
- };
52
-
53
- options.env = getEnv(options);
54
-
55
- options.stdio = normalizeStdio(options);
56
-
57
- if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
58
- // #116
59
- args.unshift('/q');
60
- }
61
-
62
- return {file, args, options, parsed};
63
- };
64
-
65
- const handleOutput = (options, value, error) => {
66
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
67
- // When `execaSync()` errors, we normalize it to '' to mimic `execa()`
68
- return error === undefined ? undefined : '';
69
- }
70
-
71
- if (options.stripFinalNewline) {
72
- return stripFinalNewline(value);
73
- }
74
-
75
- return value;
76
- };
77
-
78
- export function execa(file, args, options) {
79
- const parsed = handleArguments(file, args, options);
80
- const command = joinCommand(file, args);
81
- const escapedCommand = getEscapedCommand(file, args);
82
- logCommand(escapedCommand, parsed.options);
83
-
84
- validateTimeout(parsed.options);
85
-
86
- let spawned;
87
- try {
88
- spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
89
- } catch (error) {
90
- // Ensure the returned error is always both a promise and a child process
91
- const dummySpawned = new childProcess.ChildProcess();
92
- const errorPromise = Promise.reject(makeError({
93
- error,
94
- stdout: '',
95
- stderr: '',
96
- all: '',
97
- command,
98
- escapedCommand,
99
- parsed,
100
- timedOut: false,
101
- isCanceled: false,
102
- killed: false,
103
- }));
104
- mergePromise(dummySpawned, errorPromise);
105
- return dummySpawned;
106
- }
107
-
108
- const spawnedPromise = getSpawnedPromise(spawned);
109
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
110
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
111
-
112
- const context = {isCanceled: false};
113
-
114
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
115
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
116
-
117
- const handlePromise = async () => {
118
- const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
119
- const stdout = handleOutput(parsed.options, stdoutResult);
120
- const stderr = handleOutput(parsed.options, stderrResult);
121
- const all = handleOutput(parsed.options, allResult);
122
-
123
- if (error || exitCode !== 0 || signal !== null) {
124
- const returnedError = makeError({
125
- error,
126
- exitCode,
127
- signal,
128
- stdout,
129
- stderr,
130
- all,
131
- command,
132
- escapedCommand,
133
- parsed,
134
- timedOut,
135
- isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
136
- killed: spawned.killed,
137
- });
138
-
139
- if (!parsed.options.reject) {
140
- return returnedError;
141
- }
142
-
143
- throw returnedError;
144
- }
145
-
146
- return {
147
- command,
148
- escapedCommand,
149
- exitCode: 0,
150
- stdout,
151
- stderr,
152
- all,
153
- failed: false,
154
- timedOut: false,
155
- isCanceled: false,
156
- killed: false,
157
- };
158
- };
159
-
160
- const handlePromiseOnce = onetime(handlePromise);
161
-
162
- handleInput(spawned, parsed.options);
163
-
164
- spawned.all = makeAllStream(spawned, parsed.options);
165
-
166
- addPipeMethods(spawned);
167
- mergePromise(spawned, handlePromiseOnce);
168
- return spawned;
169
- }
170
-
171
- export function execaSync(file, args, options) {
172
- const parsed = handleArguments(file, args, options);
173
- const command = joinCommand(file, args);
174
- const escapedCommand = getEscapedCommand(file, args);
175
- logCommand(escapedCommand, parsed.options);
176
-
177
- const input = handleInputSync(parsed.options);
178
-
179
- let result;
180
- try {
181
- result = childProcess.spawnSync(parsed.file, parsed.args, {...parsed.options, input});
182
- } catch (error) {
183
- throw makeError({
184
- error,
185
- stdout: '',
186
- stderr: '',
187
- all: '',
188
- command,
189
- escapedCommand,
190
- parsed,
191
- timedOut: false,
192
- isCanceled: false,
193
- killed: false,
194
- });
195
- }
196
-
197
- const stdout = handleOutput(parsed.options, result.stdout, result.error);
198
- const stderr = handleOutput(parsed.options, result.stderr, result.error);
199
-
200
- if (result.error || result.status !== 0 || result.signal !== null) {
201
- const error = makeError({
202
- stdout,
203
- stderr,
204
- error: result.error,
205
- signal: result.signal,
206
- exitCode: result.status,
207
- command,
208
- escapedCommand,
209
- parsed,
210
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
211
- isCanceled: false,
212
- killed: result.signal !== null,
213
- });
214
-
215
- if (!parsed.options.reject) {
216
- return error;
217
- }
218
-
219
- throw error;
220
- }
221
-
222
- return {
223
- command,
224
- escapedCommand,
225
- exitCode: 0,
226
- stdout,
227
- stderr,
228
- failed: false,
229
- timedOut: false,
230
- isCanceled: false,
231
- killed: false,
232
- };
233
- }
234
-
235
- const normalizeScriptStdin = ({input, inputFile, stdio}) => input === undefined && inputFile === undefined && stdio === undefined
236
- ? {stdin: 'inherit'}
237
- : {};
238
-
239
- const normalizeScriptOptions = (options = {}) => ({
240
- preferLocal: true,
241
- ...normalizeScriptStdin(options),
242
- ...options,
243
- });
244
-
245
- function create$(options) {
246
- function $(templatesOrOptions, ...expressions) {
247
- if (!Array.isArray(templatesOrOptions)) {
248
- return create$({...options, ...templatesOrOptions});
249
- }
250
-
251
- const [file, ...args] = parseTemplates(templatesOrOptions, expressions);
252
- return execa(file, args, normalizeScriptOptions(options));
253
- }
254
-
255
- $.sync = (templates, ...expressions) => {
256
- if (!Array.isArray(templates)) {
257
- throw new TypeError('Please use $(options).sync`command` instead of $.sync(options)`command`.');
258
- }
259
-
260
- const [file, ...args] = parseTemplates(templates, expressions);
261
- return execaSync(file, args, normalizeScriptOptions(options));
262
- };
263
-
264
- return $;
265
- }
266
-
267
- export const $ = create$();
268
-
269
- export function execaCommand(command, options) {
270
- const [file, ...args] = parseCommand(command);
271
- return execa(file, args, options);
272
- }
273
-
274
- export function execaCommandSync(command, options) {
275
- const [file, ...args] = parseCommand(command);
276
- return execaSync(file, args, options);
277
- }
278
-
279
- export function execaNode(scriptPath, args, options = {}) {
280
- if (args && !Array.isArray(args) && typeof args === 'object') {
281
- options = args;
282
- args = [];
283
- }
284
-
285
- const stdio = normalizeStdioNode(options);
286
- const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
287
-
288
- const {
289
- nodePath = process.execPath,
290
- nodeOptions = defaultExecArgv,
291
- } = options;
292
-
293
- return execa(
294
- nodePath,
295
- [
296
- ...nodeOptions,
297
- scriptPath,
298
- ...(Array.isArray(args) ? args : []),
299
- ],
300
- {
301
- ...options,
302
- stdin: undefined,
303
- stdout: undefined,
304
- stderr: undefined,
305
- stdio,
306
- shell: false,
307
- },
308
- );
309
- }
@@ -1,120 +0,0 @@
1
- import {Buffer} from 'node:buffer';
2
- import {ChildProcess} from 'node:child_process';
3
-
4
- const normalizeArgs = (file, args = []) => {
5
- if (!Array.isArray(args)) {
6
- return [file];
7
- }
8
-
9
- return [file, ...args];
10
- };
11
-
12
- const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
13
- const DOUBLE_QUOTES_REGEXP = /"/g;
14
-
15
- const escapeArg = arg => {
16
- if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
17
- return arg;
18
- }
19
-
20
- return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
21
- };
22
-
23
- export const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
24
-
25
- export const getEscapedCommand = (file, args) => normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
26
-
27
- const SPACES_REGEXP = / +/g;
28
-
29
- // Handle `execaCommand()`
30
- export const parseCommand = command => {
31
- const tokens = [];
32
- for (const token of command.trim().split(SPACES_REGEXP)) {
33
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
34
- const previousToken = tokens[tokens.length - 1];
35
- if (previousToken && previousToken.endsWith('\\')) {
36
- // Merge previous token with current one
37
- tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
38
- } else {
39
- tokens.push(token);
40
- }
41
- }
42
-
43
- return tokens;
44
- };
45
-
46
- const parseExpression = expression => {
47
- const typeOfExpression = typeof expression;
48
-
49
- if (typeOfExpression === 'string') {
50
- return expression;
51
- }
52
-
53
- if (typeOfExpression === 'number') {
54
- return String(expression);
55
- }
56
-
57
- if (
58
- typeOfExpression === 'object'
59
- && expression !== null
60
- && !(expression instanceof ChildProcess)
61
- && 'stdout' in expression
62
- ) {
63
- const typeOfStdout = typeof expression.stdout;
64
-
65
- if (typeOfStdout === 'string') {
66
- return expression.stdout;
67
- }
68
-
69
- if (Buffer.isBuffer(expression.stdout)) {
70
- return expression.stdout.toString();
71
- }
72
-
73
- throw new TypeError(`Unexpected "${typeOfStdout}" stdout in template expression`);
74
- }
75
-
76
- throw new TypeError(`Unexpected "${typeOfExpression}" in template expression`);
77
- };
78
-
79
- const concatTokens = (tokens, nextTokens, isNew) => isNew || tokens.length === 0 || nextTokens.length === 0
80
- ? [...tokens, ...nextTokens]
81
- : [
82
- ...tokens.slice(0, -1),
83
- `${tokens[tokens.length - 1]}${nextTokens[0]}`,
84
- ...nextTokens.slice(1),
85
- ];
86
-
87
- const parseTemplate = ({templates, expressions, tokens, index, template}) => {
88
- const templateString = template ?? templates.raw[index];
89
- const templateTokens = templateString.split(SPACES_REGEXP).filter(Boolean);
90
- const newTokens = concatTokens(
91
- tokens,
92
- templateTokens,
93
- templateString.startsWith(' '),
94
- );
95
-
96
- if (index === expressions.length) {
97
- return newTokens;
98
- }
99
-
100
- const expression = expressions[index];
101
- const expressionTokens = Array.isArray(expression)
102
- ? expression.map(expression => parseExpression(expression))
103
- : [parseExpression(expression)];
104
- return concatTokens(
105
- newTokens,
106
- expressionTokens,
107
- templateString.endsWith(' '),
108
- );
109
- };
110
-
111
- export const parseTemplates = (templates, expressions) => {
112
- let tokens = [];
113
-
114
- for (const [index, template] of templates.entries()) {
115
- tokens = parseTemplate({templates, expressions, tokens, index, template});
116
- }
117
-
118
- return tokens;
119
- };
120
-
@@ -1,87 +0,0 @@
1
- import process from 'node:process';
2
- import {signalsByName} from '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
- export 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, cwd = process.cwd()}},
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
- error.cwd = cwd;
72
-
73
- if (all !== undefined) {
74
- error.all = all;
75
- }
76
-
77
- if ('bufferedData' in error) {
78
- delete error.bufferedData;
79
- }
80
-
81
- error.failed = true;
82
- error.timedOut = Boolean(timedOut);
83
- error.isCanceled = isCanceled;
84
- error.killed = killed && !timedOut;
85
-
86
- return error;
87
- };
@@ -1,102 +0,0 @@
1
- import os from 'node:os';
2
- import onExit from 'signal-exit';
3
-
4
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
5
-
6
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
7
- export const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
8
- const killResult = kill(signal);
9
- setKillTimeout(kill, signal, options, killResult);
10
- return killResult;
11
- };
12
-
13
- const setKillTimeout = (kill, signal, options, killResult) => {
14
- if (!shouldForceKill(signal, options, killResult)) {
15
- return;
16
- }
17
-
18
- const timeout = getForceKillAfterTimeout(options);
19
- const t = setTimeout(() => {
20
- kill('SIGKILL');
21
- }, timeout);
22
-
23
- // Guarded because there's no `.unref()` when `execa` is used in the renderer
24
- // process in Electron. This cannot be tested since we don't run tests in
25
- // Electron.
26
- // istanbul ignore else
27
- if (t.unref) {
28
- t.unref();
29
- }
30
- };
31
-
32
- const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
33
-
34
- const isSigterm = signal => signal === os.constants.signals.SIGTERM
35
- || (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
36
-
37
- const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
38
- if (forceKillAfterTimeout === true) {
39
- return DEFAULT_FORCE_KILL_TIMEOUT;
40
- }
41
-
42
- if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
43
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
44
- }
45
-
46
- return forceKillAfterTimeout;
47
- };
48
-
49
- // `childProcess.cancel()`
50
- export const spawnedCancel = (spawned, context) => {
51
- const killResult = spawned.kill();
52
-
53
- if (killResult) {
54
- context.isCanceled = true;
55
- }
56
- };
57
-
58
- const timeoutKill = (spawned, signal, reject) => {
59
- spawned.kill(signal);
60
- reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
61
- };
62
-
63
- // `timeout` option handling
64
- export const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
65
- if (timeout === 0 || timeout === undefined) {
66
- return spawnedPromise;
67
- }
68
-
69
- let timeoutId;
70
- const timeoutPromise = new Promise((resolve, reject) => {
71
- timeoutId = setTimeout(() => {
72
- timeoutKill(spawned, killSignal, reject);
73
- }, timeout);
74
- });
75
-
76
- const safeSpawnedPromise = spawnedPromise.finally(() => {
77
- clearTimeout(timeoutId);
78
- });
79
-
80
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
81
- };
82
-
83
- export const validateTimeout = ({timeout}) => {
84
- if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
85
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
86
- }
87
- };
88
-
89
- // `cleanup` option handling
90
- export const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
91
- if (!cleanup || detached) {
92
- return timedPromise;
93
- }
94
-
95
- const removeExitHandler = onExit(() => {
96
- spawned.kill();
97
- });
98
-
99
- return timedPromise.finally(() => {
100
- removeExitHandler();
101
- });
102
- };
@@ -1,42 +0,0 @@
1
- import {createWriteStream} from 'node:fs';
2
- import {ChildProcess} from 'node:child_process';
3
- import {isWritableStream} from 'is-stream';
4
-
5
- const isExecaChildProcess = target => target instanceof ChildProcess && typeof target.then === 'function';
6
-
7
- const pipeToTarget = (spawned, streamName, target) => {
8
- if (typeof target === 'string') {
9
- spawned[streamName].pipe(createWriteStream(target));
10
- return spawned;
11
- }
12
-
13
- if (isWritableStream(target)) {
14
- spawned[streamName].pipe(target);
15
- return spawned;
16
- }
17
-
18
- if (!isExecaChildProcess(target)) {
19
- throw new TypeError('The second argument must be a string, a stream or an Execa child process.');
20
- }
21
-
22
- if (!isWritableStream(target.stdin)) {
23
- throw new TypeError('The target child process\'s stdin must be available.');
24
- }
25
-
26
- spawned[streamName].pipe(target.stdin);
27
- return target;
28
- };
29
-
30
- export const addPipeMethods = spawned => {
31
- if (spawned.stdout !== null) {
32
- spawned.pipeStdout = pipeToTarget.bind(undefined, spawned, 'stdout');
33
- }
34
-
35
- if (spawned.stderr !== null) {
36
- spawned.pipeStderr = pipeToTarget.bind(undefined, spawned, 'stderr');
37
- }
38
-
39
- if (spawned.all !== undefined) {
40
- spawned.pipeAll = pipeToTarget.bind(undefined, spawned, 'all');
41
- }
42
- };
@@ -1,36 +0,0 @@
1
- // eslint-disable-next-line unicorn/prefer-top-level-await
2
- const nativePromisePrototype = (async () => {})().constructor.prototype;
3
-
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
- export 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
-
21
- // Use promises instead of `child_process` events
22
- export const getSpawnedPromise = spawned => new Promise((resolve, reject) => {
23
- spawned.on('exit', (exitCode, signal) => {
24
- resolve({exitCode, signal});
25
- });
26
-
27
- spawned.on('error', error => {
28
- reject(error);
29
- });
30
-
31
- if (spawned.stdin) {
32
- spawned.stdin.on('error', error => {
33
- reject(error);
34
- });
35
- }
36
- });