Skip to content

Commit 625e520

Browse files
committed
2.0.2
1 parent 047f78c commit 625e520

File tree

3 files changed

+170
-125
lines changed

3 files changed

+170
-125
lines changed

dist/index.js

Lines changed: 167 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -3959,158 +3959,203 @@ function octokitRegisterEndpoints(octokit) {
39593959
// Note: since nyc uses this module to output coverage, any lines
39603960
// that are in the direct sync flow of nyc's outputCoverage are
39613961
// ignored, since we can never get coverage for them.
3962-
var assert = __webpack_require__(357)
3963-
var signals = __webpack_require__(654)
3964-
3965-
var EE = __webpack_require__(614)
3962+
// grab a reference to node's real process object right away
3963+
var process = global.process
3964+
3965+
const processOk = function (process) {
3966+
return process &&
3967+
typeof process === 'object' &&
3968+
typeof process.removeListener === 'function' &&
3969+
typeof process.emit === 'function' &&
3970+
typeof process.reallyExit === 'function' &&
3971+
typeof process.listeners === 'function' &&
3972+
typeof process.kill === 'function' &&
3973+
typeof process.pid === 'number' &&
3974+
typeof process.on === 'function'
3975+
}
3976+
3977+
// some kind of non-node environment, just no-op
39663978
/* istanbul ignore if */
3967-
if (typeof EE !== 'function') {
3968-
EE = EE.EventEmitter
3969-
}
3970-
3971-
var emitter
3972-
if (process.__signal_exit_emitter__) {
3973-
emitter = process.__signal_exit_emitter__
3979+
if (!processOk(process)) {
3980+
module.exports = function () {
3981+
return function () {}
3982+
}
39743983
} else {
3975-
emitter = process.__signal_exit_emitter__ = new EE()
3976-
emitter.count = 0
3977-
emitter.emitted = {}
3978-
}
3984+
var assert = __webpack_require__(357)
3985+
var signals = __webpack_require__(654)
3986+
var isWin = /^win/i.test(process.platform)
39793987

3980-
// Because this emitter is a global, we have to check to see if a
3981-
// previous version of this library failed to enable infinite listeners.
3982-
// I know what you're about to say. But literally everything about
3983-
// signal-exit is a compromise with evil. Get used to it.
3984-
if (!emitter.infinite) {
3985-
emitter.setMaxListeners(Infinity)
3986-
emitter.infinite = true
3987-
}
3988-
3989-
module.exports = function (cb, opts) {
3990-
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
3988+
var EE = __webpack_require__(614)
3989+
/* istanbul ignore if */
3990+
if (typeof EE !== 'function') {
3991+
EE = EE.EventEmitter
3992+
}
39913993

3992-
if (loaded === false) {
3993-
load()
3994+
var emitter
3995+
if (process.__signal_exit_emitter__) {
3996+
emitter = process.__signal_exit_emitter__
3997+
} else {
3998+
emitter = process.__signal_exit_emitter__ = new EE()
3999+
emitter.count = 0
4000+
emitter.emitted = {}
39944001
}
39954002

3996-
var ev = 'exit'
3997-
if (opts && opts.alwaysLast) {
3998-
ev = 'afterexit'
4003+
// Because this emitter is a global, we have to check to see if a
4004+
// previous version of this library failed to enable infinite listeners.
4005+
// I know what you're about to say. But literally everything about
4006+
// signal-exit is a compromise with evil. Get used to it.
4007+
if (!emitter.infinite) {
4008+
emitter.setMaxListeners(Infinity)
4009+
emitter.infinite = true
39994010
}
40004011

4001-
var remove = function () {
4002-
emitter.removeListener(ev, cb)
4003-
if (emitter.listeners('exit').length === 0 &&
4004-
emitter.listeners('afterexit').length === 0) {
4005-
unload()
4012+
module.exports = function (cb, opts) {
4013+
/* istanbul ignore if */
4014+
if (!processOk(global.process)) {
4015+
return function () {}
40064016
}
4007-
}
4008-
emitter.on(ev, cb)
4017+
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
40094018

4010-
return remove
4011-
}
4019+
if (loaded === false) {
4020+
load()
4021+
}
40124022

4013-
module.exports.unload = unload
4014-
function unload () {
4015-
if (!loaded) {
4016-
return
4017-
}
4018-
loaded = false
4023+
var ev = 'exit'
4024+
if (opts && opts.alwaysLast) {
4025+
ev = 'afterexit'
4026+
}
40194027

4020-
signals.forEach(function (sig) {
4021-
try {
4022-
process.removeListener(sig, sigListeners[sig])
4023-
} catch (er) {}
4024-
})
4025-
process.emit = originalProcessEmit
4026-
process.reallyExit = originalProcessReallyExit
4027-
emitter.count -= 1
4028-
}
4028+
var remove = function () {
4029+
emitter.removeListener(ev, cb)
4030+
if (emitter.listeners('exit').length === 0 &&
4031+
emitter.listeners('afterexit').length === 0) {
4032+
unload()
4033+
}
4034+
}
4035+
emitter.on(ev, cb)
40294036

4030-
function emit (event, code, signal) {
4031-
if (emitter.emitted[event]) {
4032-
return
4037+
return remove
40334038
}
4034-
emitter.emitted[event] = true
4035-
emitter.emit(event, code, signal)
4036-
}
4037-
4038-
// { <signal>: <listener fn>, ... }
4039-
var sigListeners = {}
4040-
signals.forEach(function (sig) {
4041-
sigListeners[sig] = function listener () {
4042-
// If there are no other listeners, an exit is coming!
4043-
// Simplest way: remove us and then re-send the signal.
4044-
// We know that this will kill the process, so we can
4045-
// safely emit now.
4046-
var listeners = process.listeners(sig)
4047-
if (listeners.length === emitter.count) {
4048-
unload()
4049-
emit('exit', null, sig)
4050-
/* istanbul ignore next */
4051-
emit('afterexit', null, sig)
4052-
/* istanbul ignore next */
4053-
process.kill(process.pid, sig)
4039+
4040+
var unload = function unload () {
4041+
if (!loaded || !processOk(global.process)) {
4042+
return
40544043
}
4055-
}
4056-
})
4044+
loaded = false
40574045

4058-
module.exports.signals = function () {
4059-
return signals
4060-
}
4046+
signals.forEach(function (sig) {
4047+
try {
4048+
process.removeListener(sig, sigListeners[sig])
4049+
} catch (er) {}
4050+
})
4051+
process.emit = originalProcessEmit
4052+
process.reallyExit = originalProcessReallyExit
4053+
emitter.count -= 1
4054+
}
4055+
module.exports.unload = unload
40614056

4062-
module.exports.load = load
4057+
var emit = function emit (event, code, signal) {
4058+
/* istanbul ignore if */
4059+
if (emitter.emitted[event]) {
4060+
return
4061+
}
4062+
emitter.emitted[event] = true
4063+
emitter.emit(event, code, signal)
4064+
}
40634065

4064-
var loaded = false
4066+
// { <signal>: <listener fn>, ... }
4067+
var sigListeners = {}
4068+
signals.forEach(function (sig) {
4069+
sigListeners[sig] = function listener () {
4070+
/* istanbul ignore if */
4071+
if (!processOk(global.process)) {
4072+
return
4073+
}
4074+
// If there are no other listeners, an exit is coming!
4075+
// Simplest way: remove us and then re-send the signal.
4076+
// We know that this will kill the process, so we can
4077+
// safely emit now.
4078+
var listeners = process.listeners(sig)
4079+
if (listeners.length === emitter.count) {
4080+
unload()
4081+
emit('exit', null, sig)
4082+
/* istanbul ignore next */
4083+
emit('afterexit', null, sig)
4084+
/* istanbul ignore next */
4085+
if (isWin && sig === 'SIGHUP') {
4086+
// "SIGHUP" throws an `ENOSYS` error on Windows,
4087+
// so use a supported signal instead
4088+
sig = 'SIGINT'
4089+
}
4090+
/* istanbul ignore next */
4091+
process.kill(process.pid, sig)
4092+
}
4093+
}
4094+
})
40654095

4066-
function load () {
4067-
if (loaded) {
4068-
return
4096+
module.exports.signals = function () {
4097+
return signals
40694098
}
4070-
loaded = true
40714099

4072-
// This is the number of onSignalExit's that are in play.
4073-
// It's important so that we can count the correct number of
4074-
// listeners on signals, and don't wait for the other one to
4075-
// handle it instead of us.
4076-
emitter.count += 1
4100+
var loaded = false
40774101

4078-
signals = signals.filter(function (sig) {
4079-
try {
4080-
process.on(sig, sigListeners[sig])
4081-
return true
4082-
} catch (er) {
4083-
return false
4102+
var load = function load () {
4103+
if (loaded || !processOk(global.process)) {
4104+
return
40844105
}
4085-
})
4106+
loaded = true
40864107

4087-
process.emit = processEmit
4088-
process.reallyExit = processReallyExit
4089-
}
4108+
// This is the number of onSignalExit's that are in play.
4109+
// It's important so that we can count the correct number of
4110+
// listeners on signals, and don't wait for the other one to
4111+
// handle it instead of us.
4112+
emitter.count += 1
40904113

4091-
var originalProcessReallyExit = process.reallyExit
4092-
function processReallyExit (code) {
4093-
process.exitCode = code || 0
4094-
emit('exit', process.exitCode, null)
4095-
/* istanbul ignore next */
4096-
emit('afterexit', process.exitCode, null)
4097-
/* istanbul ignore next */
4098-
originalProcessReallyExit.call(process, process.exitCode)
4099-
}
4114+
signals = signals.filter(function (sig) {
4115+
try {
4116+
process.on(sig, sigListeners[sig])
4117+
return true
4118+
} catch (er) {
4119+
return false
4120+
}
4121+
})
4122+
4123+
process.emit = processEmit
4124+
process.reallyExit = processReallyExit
4125+
}
4126+
module.exports.load = load
41004127

4101-
var originalProcessEmit = process.emit
4102-
function processEmit (ev, arg) {
4103-
if (ev === 'exit') {
4104-
if (arg !== undefined) {
4105-
process.exitCode = arg
4128+
var originalProcessReallyExit = process.reallyExit
4129+
var processReallyExit = function processReallyExit (code) {
4130+
/* istanbul ignore if */
4131+
if (!processOk(global.process)) {
4132+
return
41064133
}
4107-
var ret = originalProcessEmit.apply(this, arguments)
4134+
process.exitCode = code || /* istanbul ignore next */ 0
41084135
emit('exit', process.exitCode, null)
41094136
/* istanbul ignore next */
41104137
emit('afterexit', process.exitCode, null)
4111-
return ret
4112-
} else {
4113-
return originalProcessEmit.apply(this, arguments)
4138+
/* istanbul ignore next */
4139+
originalProcessReallyExit.call(process, process.exitCode)
4140+
}
4141+
4142+
var originalProcessEmit = process.emit
4143+
var processEmit = function processEmit (ev, arg) {
4144+
if (ev === 'exit' && processOk(global.process)) {
4145+
/* istanbul ignore else */
4146+
if (arg !== undefined) {
4147+
process.exitCode = arg
4148+
}
4149+
var ret = originalProcessEmit.apply(this, arguments)
4150+
/* istanbul ignore next */
4151+
emit('exit', process.exitCode, null)
4152+
/* istanbul ignore next */
4153+
emit('afterexit', process.exitCode, null)
4154+
/* istanbul ignore next */
4155+
return ret
4156+
} else {
4157+
return originalProcessEmit.apply(this, arguments)
4158+
}
41144159
}
41154160
}
41164161

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "approve-pull-request-action",
33
"private": true,
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"license": "MIT",
66
"description": "GitHub Action for approving pull requests",
77
"repository": "juliangruber/approve-pull-request-action",

0 commit comments

Comments
 (0)