@percy/cli-exec 1.32.12-beta.2 → 1.32.12-beta.4
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.
- package/dist/exec.js +30 -6
- package/package.json +4 -4
package/dist/exec.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os from 'os';
|
|
1
2
|
import command from '@percy/cli-command';
|
|
2
3
|
import logger from '@percy/logger';
|
|
3
4
|
import start from './start.js';
|
|
@@ -173,15 +174,38 @@ async function* spawn(cmd, args, percy) {
|
|
|
173
174
|
process.stderr.write(`${data}`);
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
|
|
178
|
+
// wake the current wait as soon as the child errors or closes. A child killed by a signal
|
|
179
|
+
// closes with a null code, so report it the way shells do (128 + signal number); `| 0`
|
|
180
|
+
// keeps an unmapped signal at a non-zero 128 rather than NaN
|
|
181
|
+
let done = false;
|
|
182
|
+
let wake;
|
|
183
|
+
proc.on('error', err => {
|
|
184
|
+
done = true;
|
|
185
|
+
error = err;
|
|
186
|
+
wake();
|
|
187
|
+
});
|
|
188
|
+
proc.on('close', (code, signal) => {
|
|
189
|
+
done = true;
|
|
190
|
+
closed = code ?? 128 + (os.constants.signals[signal] | 0);
|
|
191
|
+
wake();
|
|
179
192
|
});
|
|
180
193
|
|
|
181
|
-
// run until an event is triggered
|
|
194
|
+
// run until an event is triggered. Waiting on the exit event rather than spinning on
|
|
195
|
+
// setImmediate keeps an idle child from costing a CPU core (percy/cli#2460), and the
|
|
196
|
+
// periodic wake lets an abort signal interrupt the generator promptly. Each tick waits on
|
|
197
|
+
// a fresh promise: racing one long-lived exit promise would retain a reaction per tick.
|
|
182
198
|
/* eslint-disable-next-line no-unmodified-loop-condition */
|
|
183
|
-
while (
|
|
184
|
-
|
|
199
|
+
while (!done) {
|
|
200
|
+
let timer;
|
|
201
|
+
try {
|
|
202
|
+
yield new Promise(resolve => {
|
|
203
|
+
wake = resolve;
|
|
204
|
+
timer = setTimeout(resolve, 100);
|
|
205
|
+
});
|
|
206
|
+
} finally {
|
|
207
|
+
clearTimeout(timer);
|
|
208
|
+
}
|
|
185
209
|
}
|
|
186
210
|
if (error) throw error;
|
|
187
211
|
return [closed];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-exec",
|
|
3
|
-
"version": "1.32.12-beta.
|
|
3
|
+
"version": "1.32.12-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@percy/cli-command": "1.32.12-beta.
|
|
38
|
-
"@percy/logger": "1.32.12-beta.
|
|
37
|
+
"@percy/cli-command": "1.32.12-beta.4",
|
|
38
|
+
"@percy/logger": "1.32.12-beta.4",
|
|
39
39
|
"cross-spawn": "^7.0.3",
|
|
40
40
|
"which": "^2.0.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "916cdcd8854848b48c3d658d9d01779176feb2d0"
|
|
43
43
|
}
|