snyk 1.1235.0 → 1.1237.0

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/cli/index.js CHANGED
@@ -35988,164 +35988,203 @@ module.exports = {
35988
35988
  // Note: since nyc uses this module to output coverage, any lines
35989
35989
  // that are in the direct sync flow of nyc's outputCoverage are
35990
35990
  // ignored, since we can never get coverage for them.
35991
- var assert = __webpack_require__(39491)
35992
- var signals = __webpack_require__(85397)
35993
- var isWin = /^win/i.test(process.platform)
35994
-
35995
- var EE = __webpack_require__(82361)
35991
+ // grab a reference to node's real process object right away
35992
+ var process = global.process
35993
+
35994
+ const processOk = function (process) {
35995
+ return process &&
35996
+ typeof process === 'object' &&
35997
+ typeof process.removeListener === 'function' &&
35998
+ typeof process.emit === 'function' &&
35999
+ typeof process.reallyExit === 'function' &&
36000
+ typeof process.listeners === 'function' &&
36001
+ typeof process.kill === 'function' &&
36002
+ typeof process.pid === 'number' &&
36003
+ typeof process.on === 'function'
36004
+ }
36005
+
36006
+ // some kind of non-node environment, just no-op
35996
36007
  /* istanbul ignore if */
35997
- if (typeof EE !== 'function') {
35998
- EE = EE.EventEmitter
35999
- }
36000
-
36001
- var emitter
36002
- if (process.__signal_exit_emitter__) {
36003
- emitter = process.__signal_exit_emitter__
36008
+ if (!processOk(process)) {
36009
+ module.exports = function () {
36010
+ return function () {}
36011
+ }
36004
36012
  } else {
36005
- emitter = process.__signal_exit_emitter__ = new EE()
36006
- emitter.count = 0
36007
- emitter.emitted = {}
36008
- }
36013
+ var assert = __webpack_require__(39491)
36014
+ var signals = __webpack_require__(85397)
36015
+ var isWin = /^win/i.test(process.platform)
36009
36016
 
36010
- // Because this emitter is a global, we have to check to see if a
36011
- // previous version of this library failed to enable infinite listeners.
36012
- // I know what you're about to say. But literally everything about
36013
- // signal-exit is a compromise with evil. Get used to it.
36014
- if (!emitter.infinite) {
36015
- emitter.setMaxListeners(Infinity)
36016
- emitter.infinite = true
36017
- }
36018
-
36019
- module.exports = function (cb, opts) {
36020
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
36021
-
36022
- if (loaded === false) {
36023
- load()
36017
+ var EE = __webpack_require__(82361)
36018
+ /* istanbul ignore if */
36019
+ if (typeof EE !== 'function') {
36020
+ EE = EE.EventEmitter
36024
36021
  }
36025
36022
 
36026
- var ev = 'exit'
36027
- if (opts && opts.alwaysLast) {
36028
- ev = 'afterexit'
36023
+ var emitter
36024
+ if (process.__signal_exit_emitter__) {
36025
+ emitter = process.__signal_exit_emitter__
36026
+ } else {
36027
+ emitter = process.__signal_exit_emitter__ = new EE()
36028
+ emitter.count = 0
36029
+ emitter.emitted = {}
36029
36030
  }
36030
36031
 
36031
- var remove = function () {
36032
- emitter.removeListener(ev, cb)
36033
- if (emitter.listeners('exit').length === 0 &&
36034
- emitter.listeners('afterexit').length === 0) {
36035
- unload()
36036
- }
36032
+ // Because this emitter is a global, we have to check to see if a
36033
+ // previous version of this library failed to enable infinite listeners.
36034
+ // I know what you're about to say. But literally everything about
36035
+ // signal-exit is a compromise with evil. Get used to it.
36036
+ if (!emitter.infinite) {
36037
+ emitter.setMaxListeners(Infinity)
36038
+ emitter.infinite = true
36037
36039
  }
36038
- emitter.on(ev, cb)
36039
36040
 
36040
- return remove
36041
- }
36041
+ module.exports = function (cb, opts) {
36042
+ /* istanbul ignore if */
36043
+ if (!processOk(global.process)) {
36044
+ return function () {}
36045
+ }
36046
+ assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
36042
36047
 
36043
- module.exports.unload = unload
36044
- function unload () {
36045
- if (!loaded) {
36046
- return
36047
- }
36048
- loaded = false
36048
+ if (loaded === false) {
36049
+ load()
36050
+ }
36049
36051
 
36050
- signals.forEach(function (sig) {
36051
- try {
36052
- process.removeListener(sig, sigListeners[sig])
36053
- } catch (er) {}
36054
- })
36055
- process.emit = originalProcessEmit
36056
- process.reallyExit = originalProcessReallyExit
36057
- emitter.count -= 1
36058
- }
36052
+ var ev = 'exit'
36053
+ if (opts && opts.alwaysLast) {
36054
+ ev = 'afterexit'
36055
+ }
36059
36056
 
36060
- function emit (event, code, signal) {
36061
- if (emitter.emitted[event]) {
36062
- return
36063
- }
36064
- emitter.emitted[event] = true
36065
- emitter.emit(event, code, signal)
36066
- }
36067
-
36068
- // { <signal>: <listener fn>, ... }
36069
- var sigListeners = {}
36070
- signals.forEach(function (sig) {
36071
- sigListeners[sig] = function listener () {
36072
- // If there are no other listeners, an exit is coming!
36073
- // Simplest way: remove us and then re-send the signal.
36074
- // We know that this will kill the process, so we can
36075
- // safely emit now.
36076
- var listeners = process.listeners(sig)
36077
- if (listeners.length === emitter.count) {
36078
- unload()
36079
- emit('exit', null, sig)
36080
- /* istanbul ignore next */
36081
- emit('afterexit', null, sig)
36082
- /* istanbul ignore next */
36083
- if (isWin && sig === 'SIGHUP') {
36084
- // "SIGHUP" throws an `ENOSYS` error on Windows,
36085
- // so use a supported signal instead
36086
- sig = 'SIGINT'
36057
+ var remove = function () {
36058
+ emitter.removeListener(ev, cb)
36059
+ if (emitter.listeners('exit').length === 0 &&
36060
+ emitter.listeners('afterexit').length === 0) {
36061
+ unload()
36087
36062
  }
36088
- process.kill(process.pid, sig)
36089
36063
  }
36064
+ emitter.on(ev, cb)
36065
+
36066
+ return remove
36090
36067
  }
36091
- })
36092
36068
 
36093
- module.exports.signals = function () {
36094
- return signals
36095
- }
36069
+ var unload = function unload () {
36070
+ if (!loaded || !processOk(global.process)) {
36071
+ return
36072
+ }
36073
+ loaded = false
36096
36074
 
36097
- module.exports.load = load
36075
+ signals.forEach(function (sig) {
36076
+ try {
36077
+ process.removeListener(sig, sigListeners[sig])
36078
+ } catch (er) {}
36079
+ })
36080
+ process.emit = originalProcessEmit
36081
+ process.reallyExit = originalProcessReallyExit
36082
+ emitter.count -= 1
36083
+ }
36084
+ module.exports.unload = unload
36098
36085
 
36099
- var loaded = false
36086
+ var emit = function emit (event, code, signal) {
36087
+ /* istanbul ignore if */
36088
+ if (emitter.emitted[event]) {
36089
+ return
36090
+ }
36091
+ emitter.emitted[event] = true
36092
+ emitter.emit(event, code, signal)
36093
+ }
36100
36094
 
36101
- function load () {
36102
- if (loaded) {
36103
- return
36095
+ // { <signal>: <listener fn>, ... }
36096
+ var sigListeners = {}
36097
+ signals.forEach(function (sig) {
36098
+ sigListeners[sig] = function listener () {
36099
+ /* istanbul ignore if */
36100
+ if (!processOk(global.process)) {
36101
+ return
36102
+ }
36103
+ // If there are no other listeners, an exit is coming!
36104
+ // Simplest way: remove us and then re-send the signal.
36105
+ // We know that this will kill the process, so we can
36106
+ // safely emit now.
36107
+ var listeners = process.listeners(sig)
36108
+ if (listeners.length === emitter.count) {
36109
+ unload()
36110
+ emit('exit', null, sig)
36111
+ /* istanbul ignore next */
36112
+ emit('afterexit', null, sig)
36113
+ /* istanbul ignore next */
36114
+ if (isWin && sig === 'SIGHUP') {
36115
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
36116
+ // so use a supported signal instead
36117
+ sig = 'SIGINT'
36118
+ }
36119
+ /* istanbul ignore next */
36120
+ process.kill(process.pid, sig)
36121
+ }
36122
+ }
36123
+ })
36124
+
36125
+ module.exports.signals = function () {
36126
+ return signals
36104
36127
  }
36105
- loaded = true
36106
36128
 
36107
- // This is the number of onSignalExit's that are in play.
36108
- // It's important so that we can count the correct number of
36109
- // listeners on signals, and don't wait for the other one to
36110
- // handle it instead of us.
36111
- emitter.count += 1
36129
+ var loaded = false
36112
36130
 
36113
- signals = signals.filter(function (sig) {
36114
- try {
36115
- process.on(sig, sigListeners[sig])
36116
- return true
36117
- } catch (er) {
36118
- return false
36131
+ var load = function load () {
36132
+ if (loaded || !processOk(global.process)) {
36133
+ return
36119
36134
  }
36120
- })
36135
+ loaded = true
36121
36136
 
36122
- process.emit = processEmit
36123
- process.reallyExit = processReallyExit
36124
- }
36137
+ // This is the number of onSignalExit's that are in play.
36138
+ // It's important so that we can count the correct number of
36139
+ // listeners on signals, and don't wait for the other one to
36140
+ // handle it instead of us.
36141
+ emitter.count += 1
36125
36142
 
36126
- var originalProcessReallyExit = process.reallyExit
36127
- function processReallyExit (code) {
36128
- process.exitCode = code || 0
36129
- emit('exit', process.exitCode, null)
36130
- /* istanbul ignore next */
36131
- emit('afterexit', process.exitCode, null)
36132
- /* istanbul ignore next */
36133
- originalProcessReallyExit.call(process, process.exitCode)
36134
- }
36143
+ signals = signals.filter(function (sig) {
36144
+ try {
36145
+ process.on(sig, sigListeners[sig])
36146
+ return true
36147
+ } catch (er) {
36148
+ return false
36149
+ }
36150
+ })
36151
+
36152
+ process.emit = processEmit
36153
+ process.reallyExit = processReallyExit
36154
+ }
36155
+ module.exports.load = load
36135
36156
 
36136
- var originalProcessEmit = process.emit
36137
- function processEmit (ev, arg) {
36138
- if (ev === 'exit') {
36139
- if (arg !== undefined) {
36140
- process.exitCode = arg
36157
+ var originalProcessReallyExit = process.reallyExit
36158
+ var processReallyExit = function processReallyExit (code) {
36159
+ /* istanbul ignore if */
36160
+ if (!processOk(global.process)) {
36161
+ return
36141
36162
  }
36142
- var ret = originalProcessEmit.apply(this, arguments)
36163
+ process.exitCode = code || /* istanbul ignore next */ 0
36143
36164
  emit('exit', process.exitCode, null)
36144
36165
  /* istanbul ignore next */
36145
36166
  emit('afterexit', process.exitCode, null)
36146
- return ret
36147
- } else {
36148
- return originalProcessEmit.apply(this, arguments)
36167
+ /* istanbul ignore next */
36168
+ originalProcessReallyExit.call(process, process.exitCode)
36169
+ }
36170
+
36171
+ var originalProcessEmit = process.emit
36172
+ var processEmit = function processEmit (ev, arg) {
36173
+ if (ev === 'exit' && processOk(global.process)) {
36174
+ /* istanbul ignore else */
36175
+ if (arg !== undefined) {
36176
+ process.exitCode = arg
36177
+ }
36178
+ var ret = originalProcessEmit.apply(this, arguments)
36179
+ /* istanbul ignore next */
36180
+ emit('exit', process.exitCode, null)
36181
+ /* istanbul ignore next */
36182
+ emit('afterexit', process.exitCode, null)
36183
+ /* istanbul ignore next */
36184
+ return ret
36185
+ } else {
36186
+ return originalProcessEmit.apply(this, arguments)
36187
+ }
36149
36188
  }
36150
36189
  }
36151
36190