Skip to content

Commit

Permalink
deps: signal-exit@4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Nov 14, 2023
1 parent 1acb277 commit 54c4f7b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
31 changes: 19 additions & 12 deletions node_modules/signal-exit/dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const processOk = (process) => !!process &&
const kExitEmitter = Symbol.for('signal-exit emitter');
const global = globalThis;
const ObjectDefineProperty = Object.defineProperty.bind(Object);
// teeny tiny ee
// teeny special purpose ee
class Emitter {
emitted = {
afterExit: false,
Expand Down Expand Up @@ -63,12 +63,17 @@ class Emitter {
}
emit(ev, code, signal) {
if (this.emitted[ev]) {
return;
return false;
}
this.emitted[ev] = true;
let ret = false;
for (const fn of this.listeners[ev]) {
fn(code, signal);
ret = fn(code, signal) === true || ret;
}
if (ev === 'exit') {
ret = this.emit('afterExit', code, signal) || ret;
}
return ret;
}
}
class SignalExitBase {
Expand Down Expand Up @@ -122,18 +127,22 @@ class SignalExit extends SignalExitBase {
// exit v4 are not aware of each other, and each will attempt to let
// the other handle it, so neither of them do. To correct this, we
// detect if we're the only handler *except* for previous versions
// of signal-exit.
// of signal-exit, and increment by the count of listeners it has
// created.
/* c8 ignore start */
//@ts-ignore
if (typeof process.__signal_exit_emitter__ === 'object')
count++;
const p = process;
if (typeof p.__signal_exit_emitter__ === 'object' &&
typeof p.__signal_exit_emitter__.count === 'number') {
count += p.__signal_exit_emitter__.count;
}
/* c8 ignore stop */
if (listeners.length === count) {
this.unload();
this.#emitter.emit('exit', null, sig);
this.#emitter.emit('afterExit', null, sig);
const ret = this.#emitter.emit('exit', null, sig);
/* c8 ignore start */
process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
const s = sig === 'SIGHUP' ? this.#hupSig : sig;
if (!ret)
process.kill(process.pid, s);
/* c8 ignore stop */
}
};
Expand Down Expand Up @@ -216,7 +225,6 @@ class SignalExit extends SignalExitBase {
this.#process.exitCode = code || 0;
/* c8 ignore stop */
this.#emitter.emit('exit', this.#process.exitCode, null);
this.#emitter.emit('afterExit', this.#process.exitCode, null);
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
}
#processEmit(ev, ...args) {
Expand All @@ -230,7 +238,6 @@ class SignalExit extends SignalExitBase {
const ret = og.call(this.#process, ev, ...args);
/* c8 ignore start */
this.#emitter.emit('exit', this.#process.exitCode, null);
this.#emitter.emit('afterExit', this.#process.exitCode, null);
/* c8 ignore stop */
return ret;
}
Expand Down
31 changes: 19 additions & 12 deletions node_modules/signal-exit/dist/mjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const processOk = (process) => !!process &&
const kExitEmitter = Symbol.for('signal-exit emitter');
const global = globalThis;
const ObjectDefineProperty = Object.defineProperty.bind(Object);
// teeny tiny ee
// teeny special purpose ee
class Emitter {
emitted = {
afterExit: false,
Expand Down Expand Up @@ -59,12 +59,17 @@ class Emitter {
}
emit(ev, code, signal) {
if (this.emitted[ev]) {
return;
return false;
}
this.emitted[ev] = true;
let ret = false;
for (const fn of this.listeners[ev]) {
fn(code, signal);
ret = fn(code, signal) === true || ret;
}
if (ev === 'exit') {
ret = this.emit('afterExit', code, signal) || ret;
}
return ret;
}
}
class SignalExitBase {
Expand Down Expand Up @@ -118,18 +123,22 @@ class SignalExit extends SignalExitBase {
// exit v4 are not aware of each other, and each will attempt to let
// the other handle it, so neither of them do. To correct this, we
// detect if we're the only handler *except* for previous versions
// of signal-exit.
// of signal-exit, and increment by the count of listeners it has
// created.
/* c8 ignore start */
//@ts-ignore
if (typeof process.__signal_exit_emitter__ === 'object')
count++;
const p = process;
if (typeof p.__signal_exit_emitter__ === 'object' &&
typeof p.__signal_exit_emitter__.count === 'number') {
count += p.__signal_exit_emitter__.count;
}
/* c8 ignore stop */
if (listeners.length === count) {
this.unload();
this.#emitter.emit('exit', null, sig);
this.#emitter.emit('afterExit', null, sig);
const ret = this.#emitter.emit('exit', null, sig);
/* c8 ignore start */
process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
const s = sig === 'SIGHUP' ? this.#hupSig : sig;
if (!ret)
process.kill(process.pid, s);
/* c8 ignore stop */
}
};
Expand Down Expand Up @@ -212,7 +221,6 @@ class SignalExit extends SignalExitBase {
this.#process.exitCode = code || 0;
/* c8 ignore stop */
this.#emitter.emit('exit', this.#process.exitCode, null);
this.#emitter.emit('afterExit', this.#process.exitCode, null);
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
}
#processEmit(ev, ...args) {
Expand All @@ -226,7 +234,6 @@ class SignalExit extends SignalExitBase {
const ret = og.call(this.#process, ev, ...args);
/* c8 ignore start */
this.#emitter.emit('exit', this.#process.exitCode, null);
this.#emitter.emit('afterExit', this.#process.exitCode, null);
/* c8 ignore stop */
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion node_modules/signal-exit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "signal-exit",
"version": "4.0.2",
"version": "4.1.0",
"description": "when you want to fire an event no matter how a process exits.",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -13502,9 +13502,9 @@
}
},
"node_modules/signal-exit": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz",
"integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"inBundle": true,
"engines": {
"node": ">=14"
Expand Down

0 comments on commit 54c4f7b

Please sign in to comment.