@percy/cli-command 1.32.0-beta.7 → 1.32.0-beta.9
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/command.js +33 -11
- package/package.json +5 -5
package/dist/command.js
CHANGED
|
@@ -30,12 +30,20 @@ let shutdownState = {
|
|
|
30
30
|
let activeContext = null;
|
|
31
31
|
const DEFAULT_DRAIN_MS = 30_000;
|
|
32
32
|
const HARD_EXIT_AFTER_FORCE_MS = 5_000;
|
|
33
|
-
// POSIX-conventional signal exit codes: 128 + signal number.
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// POSIX-conventional signal exit codes: 128 + signal number. SIGINT and
|
|
34
|
+
// SIGTERM additionally engage drain semantics in beginShutdown; the
|
|
35
|
+
// remaining signals only need an exit-code mapping so a signal-aborted
|
|
36
|
+
// run never resolves as a false-positive success (PER-8678).
|
|
37
|
+
const EXIT_CODE_SIGINT = 130; // 128 + 2
|
|
38
|
+
const EXIT_CODE_SIGTERM = 143; // 128 + 15
|
|
36
39
|
const SIGNAL_EXIT_CODES = {
|
|
37
40
|
SIGINT: EXIT_CODE_SIGINT,
|
|
38
|
-
SIGTERM: EXIT_CODE_SIGTERM
|
|
41
|
+
SIGTERM: EXIT_CODE_SIGTERM,
|
|
42
|
+
SIGHUP: 129,
|
|
43
|
+
// 128 + 1
|
|
44
|
+
SIGUSR1: 138,
|
|
45
|
+
// 128 + 10
|
|
46
|
+
SIGUSR2: 140 // 128 + 12
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
// Begin or escalate drain. Idempotent on the same signal.
|
|
@@ -351,18 +359,32 @@ export function command(name, definition, callback) {
|
|
|
351
359
|
if (err.exitCode === 0) log.warn(err.message);else log.error(err);
|
|
352
360
|
}
|
|
353
361
|
|
|
354
|
-
// Signal-driven shutdown — when
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
//
|
|
362
|
+
// Signal-driven shutdown — when ANY process signal aborted this
|
|
363
|
+
// run, set the signal-derived exit code (130 SIGINT / 143 SIGTERM
|
|
364
|
+
// / 129 SIGHUP / 138 SIGUSR1 / 140 SIGUSR2, defaulting to 1 for
|
|
365
|
+
// any other signal) and return. Keying off `err.signal` (set on
|
|
366
|
+
// the AbortError by the per-signal handler) rather than
|
|
367
|
+
// `shutdownState.signal` is deliberate: beginShutdown only records
|
|
368
|
+
// SIGINT/SIGTERM into shutdownState for drain semantics, so the
|
|
369
|
+
// old `shutdownState.signal` gate let SIGHUP/SIGUSR1/SIGUSR2 fall
|
|
370
|
+
// through to the exitCode-0 AbortError path and exit 0 — a
|
|
371
|
+
// false-positive CI success when a run was aborted during startup
|
|
372
|
+
// before the wrapped command launched (PER-8678). We deliberately
|
|
373
|
+
// set `process.exitCode` and unwind cleanly rather than calling
|
|
358
374
|
// `process.exit()`, so the surrounding catch's finally block (and
|
|
359
375
|
// the lockfile's `process.on('exit')` handler) still run. The
|
|
360
376
|
// event loop drains naturally because the unref'd drain/hard-exit
|
|
361
377
|
// timers don't keep it alive. Tests with `exitOnError: false`
|
|
362
378
|
// preserve the legacy clean-resolution behavior because
|
|
363
|
-
// AbortError carries exitCode:0 and
|
|
364
|
-
if (
|
|
365
|
-
|
|
379
|
+
// AbortError carries exitCode:0 and this gate is skipped.
|
|
380
|
+
if (err.signal && definition.exitOnError) {
|
|
381
|
+
// Defensive non-zero fallback: every signal in the registered
|
|
382
|
+
// handler set above is mapped in SIGNAL_EXIT_CODES, so the `?? 1`
|
|
383
|
+
// branch only fires if a future signal is added to the handler
|
|
384
|
+
// list without a code — kept non-zero so the false-positive
|
|
385
|
+
// success can't reappear (PER-8678).
|
|
386
|
+
/* istanbul ignore next */
|
|
387
|
+
let signalCode = SIGNAL_EXIT_CODES[err.signal] ?? 1;
|
|
366
388
|
let percyExitWithZeroOnError = process.env.PERCY_EXIT_WITH_ZERO_ON_ERROR === 'true';
|
|
367
389
|
process.exitCode = percyExitWithZeroOnError ? 0 : signalCode;
|
|
368
390
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-command",
|
|
3
|
-
"version": "1.32.0-beta.
|
|
3
|
+
"version": "1.32.0-beta.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"test:coverage": "yarn test --coverage"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@percy/config": "1.32.0-beta.
|
|
41
|
-
"@percy/core": "1.32.0-beta.
|
|
42
|
-
"@percy/logger": "1.32.0-beta.
|
|
40
|
+
"@percy/config": "1.32.0-beta.9",
|
|
41
|
+
"@percy/core": "1.32.0-beta.9",
|
|
42
|
+
"@percy/logger": "1.32.0-beta.9",
|
|
43
43
|
"glob-to-regexp": "^0.4.1",
|
|
44
44
|
"stream-json": "^1.8.0"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
47
|
"snyk-nodejs-lockfile-parser": "2.7.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "cc176ec0fa5e36551db037a14186ea8b7cd07ff6"
|
|
50
50
|
}
|