Changeset e29cc2e for trip-planner-front/node_modules/signal-exit/index.js
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/signal-exit/index.js
r59329aa re29cc2e 4 4 // grab a reference to node's real process object right away 5 5 var process = global.process 6 7 const processOk = function (process) { 8 return process && 9 typeof process === 'object' && 10 typeof process.removeListener === 'function' && 11 typeof process.emit === 'function' && 12 typeof process.reallyExit === 'function' && 13 typeof process.listeners === 'function' && 14 typeof process.kill === 'function' && 15 typeof process.pid === 'number' && 16 typeof process.on === 'function' 17 } 18 6 19 // some kind of non-node environment, just no-op 7 if (typeof process !== 'object' || !process) { 20 /* istanbul ignore if */ 21 if (!processOk(process)) { 8 22 module.exports = function () {} 9 23 } else { … … 37 51 38 52 module.exports = function (cb, opts) { 39 if (global.process !== process) { 53 /* istanbul ignore if */ 54 if (!processOk(global.process)) { 40 55 return 41 56 } … … 64 79 65 80 var unload = function unload () { 66 if (!loaded || global.process !== process) {81 if (!loaded || !processOk(global.process)) { 67 82 return 68 83 } … … 81 96 82 97 var emit = function emit (event, code, signal) { 98 /* istanbul ignore if */ 83 99 if (emitter.emitted[event]) { 84 100 return … … 92 108 signals.forEach(function (sig) { 93 109 sigListeners[sig] = function listener () { 94 if (process !== global.process) { 110 /* istanbul ignore if */ 111 if (!processOk(global.process)) { 95 112 return 96 113 } … … 111 128 sig = 'SIGINT' 112 129 } 130 /* istanbul ignore next */ 113 131 process.kill(process.pid, sig) 114 132 } … … 123 141 124 142 var load = function load () { 125 if (loaded || process !== global.process) {143 if (loaded || !processOk(global.process)) { 126 144 return 127 145 } … … 150 168 var originalProcessReallyExit = process.reallyExit 151 169 var processReallyExit = function processReallyExit (code) { 152 if (process !== global.process) { 153 return 154 } 155 process.exitCode = code || 0 170 /* istanbul ignore if */ 171 if (!processOk(global.process)) { 172 return 173 } 174 process.exitCode = code || /* istanbul ignore next */ 0 156 175 emit('exit', process.exitCode, null) 157 176 /* istanbul ignore next */ … … 163 182 var originalProcessEmit = process.emit 164 183 var processEmit = function processEmit (ev, arg) { 165 if (ev === 'exit' && process === global.process) { 184 if (ev === 'exit' && processOk(global.process)) { 185 /* istanbul ignore else */ 166 186 if (arg !== undefined) { 167 187 process.exitCode = arg 168 188 } 169 189 var ret = originalProcessEmit.apply(this, arguments) 190 /* istanbul ignore next */ 170 191 emit('exit', process.exitCode, null) 171 192 /* istanbul ignore next */ 172 193 emit('afterexit', process.exitCode, null) 194 /* istanbul ignore next */ 173 195 return ret 174 196 } else {
Note:
See TracChangeset
for help on using the changeset viewer.