MCPcopy
hub / github.com/di-sukharev/opencommit / "node_modules/signal-exit/index.js"

Function "node_modules/signal-exit/index.js"

out/cli.cjs:1537–1691  ·  view source on GitHub ↗
(exports2, module2)

Source from the content-addressed store, hash-verified

1535// node_modules/signal-exit/index.js
1536var require_signal_exit = __commonJS({
1537 "node_modules/signal-exit/index.js"(exports2, module2) {
1538 var process9 = global.process;
1539 var processOk = function(process10) {
1540 return process10 && typeof process10 === "object" && typeof process10.removeListener === "function" && typeof process10.emit === "function" && typeof process10.reallyExit === "function" && typeof process10.listeners === "function" && typeof process10.kill === "function" && typeof process10.pid === "number" && typeof process10.on === "function";
1541 };
1542 if (!processOk(process9)) {
1543 module2.exports = function() {
1544 return function() {
1545 };
1546 };
1547 } else {
1548 assert2 = require("assert");
1549 signals = require_signals();
1550 isWin = /^win/i.test(process9.platform);
1551 EE = require("events");
1552 if (typeof EE !== "function") {
1553 EE = EE.EventEmitter;
1554 }
1555 if (process9.__signal_exit_emitter__) {
1556 emitter = process9.__signal_exit_emitter__;
1557 } else {
1558 emitter = process9.__signal_exit_emitter__ = new EE();
1559 emitter.count = 0;
1560 emitter.emitted = {};
1561 }
1562 if (!emitter.infinite) {
1563 emitter.setMaxListeners(Infinity);
1564 emitter.infinite = true;
1565 }
1566 module2.exports = function(cb, opts) {
1567 if (!processOk(global.process)) {
1568 return function() {
1569 };
1570 }
1571 assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
1572 if (loaded === false) {
1573 load();
1574 }
1575 var ev = "exit";
1576 if (opts && opts.alwaysLast) {
1577 ev = "afterexit";
1578 }
1579 var remove = function() {
1580 emitter.removeListener(ev, cb);
1581 if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
1582 unload();
1583 }
1584 };
1585 emitter.on(ev, cb);
1586 return remove;
1587 };
1588 unload = function unload2() {
1589 if (!loaded || !processOk(global.process)) {
1590 return;
1591 }
1592 loaded = false;
1593 signals.forEach(function(sig) {
1594 try {

Callers

nothing calls this directly

Calls 8

processOkFunction · 0.85
loadFunction · 0.85
testMethod · 0.80
removeListenerMethod · 0.80
filterMethod · 0.80
onMethod · 0.45
forEachMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…