Skip to content

Commit 54c4f7b

Browse files
committed
deps: signal-exit@4.1.0
1 parent 1acb277 commit 54c4f7b

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

node_modules/signal-exit/dist/cjs/index.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const processOk = (process) => !!process &&
2020
const kExitEmitter = Symbol.for('signal-exit emitter');
2121
const global = globalThis;
2222
const ObjectDefineProperty = Object.defineProperty.bind(Object);
23-
// teeny tiny ee
23+
// teeny special purpose ee
2424
class Emitter {
2525
emitted = {
2626
afterExit: false,
@@ -63,12 +63,17 @@ class Emitter {
6363
}
6464
emit(ev, code, signal) {
6565
if (this.emitted[ev]) {
66-
return;
66+
return false;
6767
}
6868
this.emitted[ev] = true;
69+
let ret = false;
6970
for (const fn of this.listeners[ev]) {
70-
fn(code, signal);
71+
ret = fn(code, signal) === true || ret;
72+
}
73+
if (ev === 'exit') {
74+
ret = this.emit('afterExit', code, signal) || ret;
7175
}
76+
return ret;
7277
}
7378
}
7479
class SignalExitBase {
@@ -122,18 +127,22 @@ class SignalExit extends SignalExitBase {
122127
// exit v4 are not aware of each other, and each will attempt to let
123128
// the other handle it, so neither of them do. To correct this, we
124129
// detect if we're the only handler *except* for previous versions
125-
// of signal-exit.
130+
// of signal-exit, and increment by the count of listeners it has
131+
// created.
126132
/* c8 ignore start */
127-
//@ts-ignore
128-
if (typeof process.__signal_exit_emitter__ === 'object')
129-
count++;
133+
const p = process;
134+
if (typeof p.__signal_exit_emitter__ === 'object' &&
135+
typeof p.__signal_exit_emitter__.count === 'number') {
136+
count += p.__signal_exit_emitter__.count;
137+
}
130138
/* c8 ignore stop */
131139
if (listeners.length === count) {
132140
this.unload();
133-
this.#emitter.emit('exit', null, sig);
134-
this.#emitter.emit('afterExit', null, sig);
141+
const ret = this.#emitter.emit('exit', null, sig);
135142
/* c8 ignore start */
136-
process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
143+
const s = sig === 'SIGHUP' ? this.#hupSig : sig;
144+
if (!ret)
145+
process.kill(process.pid, s);
137146
/* c8 ignore stop */
138147
}
139148
};
@@ -216,7 +225,6 @@ class SignalExit extends SignalExitBase {
216225
this.#process.exitCode = code || 0;
217226
/* c8 ignore stop */
218227
this.#emitter.emit('exit', this.#process.exitCode, null);
219-
this.#emitter.emit('afterExit', this.#process.exitCode, null);
220228
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
221229
}
222230
#processEmit(ev, ...args) {
@@ -230,7 +238,6 @@ class SignalExit extends SignalExitBase {
230238
const ret = og.call(this.#process, ev, ...args);
231239
/* c8 ignore start */
232240
this.#emitter.emit('exit', this.#process.exitCode, null);
233-
this.#emitter.emit('afterExit', this.#process.exitCode, null);
234241
/* c8 ignore stop */
235242
return ret;
236243
}

node_modules/signal-exit/dist/mjs/index.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const processOk = (process) => !!process &&
1616
const kExitEmitter = Symbol.for('signal-exit emitter');
1717
const global = globalThis;
1818
const ObjectDefineProperty = Object.defineProperty.bind(Object);
19-
// teeny tiny ee
19+
// teeny special purpose ee
2020
class Emitter {
2121
emitted = {
2222
afterExit: false,
@@ -59,12 +59,17 @@ class Emitter {
5959
}
6060
emit(ev, code, signal) {
6161
if (this.emitted[ev]) {
62-
return;
62+
return false;
6363
}
6464
this.emitted[ev] = true;
65+
let ret = false;
6566
for (const fn of this.listeners[ev]) {
66-
fn(code, signal);
67+
ret = fn(code, signal) === true || ret;
68+
}
69+
if (ev === 'exit') {
70+
ret = this.emit('afterExit', code, signal) || ret;
6771
}
72+
return ret;
6873
}
6974
}
7075
class SignalExitBase {
@@ -118,18 +123,22 @@ class SignalExit extends SignalExitBase {
118123
// exit v4 are not aware of each other, and each will attempt to let
119124
// the other handle it, so neither of them do. To correct this, we
120125
// detect if we're the only handler *except* for previous versions
121-
// of signal-exit.
126+
// of signal-exit, and increment by the count of listeners it has
127+
// created.
122128
/* c8 ignore start */
123-
//@ts-ignore
124-
if (typeof process.__signal_exit_emitter__ === 'object')
125-
count++;
129+
const p = process;
130+
if (typeof p.__signal_exit_emitter__ === 'object' &&
131+
typeof p.__signal_exit_emitter__.count === 'number') {
132+
count += p.__signal_exit_emitter__.count;
133+
}
126134
/* c8 ignore stop */
127135
if (listeners.length === count) {
128136
this.unload();
129-
this.#emitter.emit('exit', null, sig);
130-
this.#emitter.emit('afterExit', null, sig);
137+
const ret = this.#emitter.emit('exit', null, sig);
131138
/* c8 ignore start */
132-
process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
139+
const s = sig === 'SIGHUP' ? this.#hupSig : sig;
140+
if (!ret)
141+
process.kill(process.pid, s);
133142
/* c8 ignore stop */
134143
}
135144
};
@@ -212,7 +221,6 @@ class SignalExit extends SignalExitBase {
212221
this.#process.exitCode = code || 0;
213222
/* c8 ignore stop */
214223
this.#emitter.emit('exit', this.#process.exitCode, null);
215-
this.#emitter.emit('afterExit', this.#process.exitCode, null);
216224
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
217225
}
218226
#processEmit(ev, ...args) {
@@ -226,7 +234,6 @@ class SignalExit extends SignalExitBase {
226234
const ret = og.call(this.#process, ev, ...args);
227235
/* c8 ignore start */
228236
this.#emitter.emit('exit', this.#process.exitCode, null);
229-
this.#emitter.emit('afterExit', this.#process.exitCode, null);
230237
/* c8 ignore stop */
231238
return ret;
232239
}

node_modules/signal-exit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "signal-exit",
3-
"version": "4.0.2",
3+
"version": "4.1.0",
44
"description": "when you want to fire an event no matter how a process exits.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/mjs/index.js",

package-lock.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13502,9 +13502,9 @@
1350213502
}
1350313503
},
1350413504
"node_modules/signal-exit": {
13505-
"version": "4.0.2",
13506-
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz",
13507-
"integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==",
13505+
"version": "4.1.0",
13506+
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
13507+
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
1350813508
"inBundle": true,
1350913509
"engines": {
1351013510
"node": ">=14"

0 commit comments

Comments
 (0)