Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: [email protected] #4052

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions node_modules/signal-exit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
// ignored, since we can never get coverage for them.
// grab a reference to node's real process object right away
var process = global.process

const processOk = function (process) {
return process &&
typeof process === 'object' &&
typeof process.removeListener === 'function' &&
typeof process.emit === 'function' &&
typeof process.reallyExit === 'function' &&
typeof process.listeners === 'function' &&
typeof process.kill === 'function' &&
typeof process.pid === 'number' &&
typeof process.on === 'function'
}

// some kind of non-node environment, just no-op
if (typeof process !== 'object' || !process) {
/* istanbul ignore if */
if (!processOk(process)) {
module.exports = function () {}
} else {
var assert = require('assert')
Expand Down Expand Up @@ -36,7 +50,8 @@ if (typeof process !== 'object' || !process) {
}

module.exports = function (cb, opts) {
if (global.process !== process) {
/* istanbul ignore if */
if (!processOk(global.process)) {
return
}
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
Expand All @@ -63,7 +78,7 @@ if (typeof process !== 'object' || !process) {
}

var unload = function unload () {
if (!loaded || global.process !== process) {
if (!loaded || !processOk(global.process)) {
return
}
loaded = false
Expand All @@ -80,6 +95,7 @@ if (typeof process !== 'object' || !process) {
module.exports.unload = unload

var emit = function emit (event, code, signal) {
/* istanbul ignore if */
if (emitter.emitted[event]) {
return
}
Expand All @@ -91,7 +107,8 @@ if (typeof process !== 'object' || !process) {
var sigListeners = {}
signals.forEach(function (sig) {
sigListeners[sig] = function listener () {
if (process !== global.process) {
/* istanbul ignore if */
if (!processOk(global.process)) {
return
}
// If there are no other listeners, an exit is coming!
Expand All @@ -110,6 +127,7 @@ if (typeof process !== 'object' || !process) {
// so use a supported signal instead
sig = 'SIGINT'
}
/* istanbul ignore next */
process.kill(process.pid, sig)
}
}
Expand All @@ -122,7 +140,7 @@ if (typeof process !== 'object' || !process) {
var loaded = false

var load = function load () {
if (loaded || process !== global.process) {
if (loaded || !processOk(global.process)) {
return
}
loaded = true
Expand All @@ -149,10 +167,11 @@ if (typeof process !== 'object' || !process) {

var originalProcessReallyExit = process.reallyExit
var processReallyExit = function processReallyExit (code) {
if (process !== global.process) {
/* istanbul ignore if */
if (!processOk(global.process)) {
return
}
process.exitCode = code || 0
process.exitCode = code || /* istanbul ignore next */ 0
emit('exit', process.exitCode, null)
/* istanbul ignore next */
emit('afterexit', process.exitCode, null)
Expand All @@ -162,14 +181,17 @@ if (typeof process !== 'object' || !process) {

var originalProcessEmit = process.emit
var processEmit = function processEmit (ev, arg) {
if (ev === 'exit' && process === global.process) {
if (ev === 'exit' && processOk(global.process)) {
/* istanbul ignore else */
if (arg !== undefined) {
process.exitCode = arg
}
var ret = originalProcessEmit.apply(this, arguments)
/* istanbul ignore next */
emit('exit', process.exitCode, null)
/* istanbul ignore next */
emit('afterexit', process.exitCode, null)
/* istanbul ignore next */
return ret
} else {
return originalProcessEmit.apply(this, arguments)
Expand Down
12 changes: 7 additions & 5 deletions node_modules/signal-exit/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "signal-exit",
"version": "3.0.5",
"version": "3.0.6",
"description": "when you want to fire an event no matter how a process exits.",
"main": "index.js",
"scripts": {
"test": "tap --timeout=240 ./test/*.js --cov",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"release": "standard-version"
"test": "tap",
"snap": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags"
},
"files": [
"index.js",
Expand All @@ -31,6 +33,6 @@
"coveralls": "^3.1.1",
"nyc": "^15.1.0",
"standard-version": "^9.3.1",
"tap": "^15.0.10"
"tap": "^15.1.1"
}
}
34 changes: 17 additions & 17 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"eslint": "^8.2.0",
"licensee": "^8.2.0",
"spawk": "^1.7.1",
"tap": "^15.1.1"
"tap": "^15.1.2"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16"
Expand Down Expand Up @@ -6660,9 +6660,9 @@
}
},
"node_modules/signal-exit": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz",
"integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==",
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
"inBundle": true
},
"node_modules/simple-concat": {
Expand Down Expand Up @@ -7068,9 +7068,9 @@
"dev": true
},
"node_modules/tap": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/tap/-/tap-15.1.1.tgz",
"integrity": "sha512-7g9WaBK8Cp3f3Ry+OFTwhDjnEjJGGsylOT3V7N+hcONYgSpnhbgVp9ZIyAt++YTwBkRrE/6NxKCCf0MbSiToCg==",
"version": "15.1.2",
"resolved": "https://registry.npmjs.org/tap/-/tap-15.1.2.tgz",
"integrity": "sha512-32FftTGFDnWs6/mcaLm2d6AZ1kMq94w8ybhpnwL4CZYtWIHcp6FyT+NFaZZcajI8NqSXCYku88PMEDMY6vykEw==",
"bundleDependencies": [
"ink",
"treport",
Expand Down Expand Up @@ -7099,7 +7099,7 @@
"opener": "^1.5.1",
"react": "*",
"rimraf": "^3.0.0",
"signal-exit": "^3.0.0",
"signal-exit": "^3.0.6",
"source-map-support": "^0.5.16",
"tap-mocha-reporter": "^5.0.0",
"tap-parser": "^10.0.1",
Expand Down Expand Up @@ -8656,7 +8656,7 @@
"license": "MIT"
},
"node_modules/tap/node_modules/signal-exit": {
"version": "3.0.5",
"version": "3.0.6",
"dev": true,
"inBundle": true,
"license": "ISC"
Expand Down Expand Up @@ -14948,9 +14948,9 @@
"dev": true
},
"signal-exit": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz",
"integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ=="
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
},
"simple-concat": {
"version": "1.0.1",
Expand Down Expand Up @@ -15262,9 +15262,9 @@
"dev": true
},
"tap": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/tap/-/tap-15.1.1.tgz",
"integrity": "sha512-7g9WaBK8Cp3f3Ry+OFTwhDjnEjJGGsylOT3V7N+hcONYgSpnhbgVp9ZIyAt++YTwBkRrE/6NxKCCf0MbSiToCg==",
"version": "15.1.2",
"resolved": "https://registry.npmjs.org/tap/-/tap-15.1.2.tgz",
"integrity": "sha512-32FftTGFDnWs6/mcaLm2d6AZ1kMq94w8ybhpnwL4CZYtWIHcp6FyT+NFaZZcajI8NqSXCYku88PMEDMY6vykEw==",
"dev": true,
"requires": {
"@types/react": "*",
Expand All @@ -15286,7 +15286,7 @@
"opener": "^1.5.1",
"react": "*",
"rimraf": "^3.0.0",
"signal-exit": "^3.0.0",
"signal-exit": "^3.0.6",
"source-map-support": "^0.5.16",
"tap-mocha-reporter": "^5.0.0",
"tap-parser": "^10.0.1",
Expand Down Expand Up @@ -16252,7 +16252,7 @@
"dev": true
},
"signal-exit": {
"version": "3.0.5",
"version": "3.0.6",
"bundled": true,
"dev": true
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"eslint": "^8.2.0",
"licensee": "^8.2.0",
"spawk": "^1.7.1",
"tap": "^15.1.1"
"tap": "^15.1.2"
},
"scripts": {
"dumpconf": "env | grep npm | sort | uniq",
Expand Down
12 changes: 6 additions & 6 deletions test/lib/utils/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ t.before(async () => {
npm.config.set('cache', cacheFolder)
})

t.test('bootstrap tap before cutting off process ref', (t) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES!

t.ok('ok')
t.end()
})

// cut off process from script so that it won't quit the test runner
// while trying to run through the myriad of cases
// while trying to run through the myriad of cases. need to make it
// have all the functions signal-exit relies on so that it doesn't
// nerf itself, thinking global.process is broken or gone.
const _process = process
process = Object.assign(
new EventEmitter(),
Expand All @@ -62,6 +59,9 @@ process = Object.assign(
} },
stderr: { write () {} },
hrtime: _process.hrtime,
kill: () => {},
reallyExit: (code) => process.exit(code),
pid: 123456,
}
)

Expand Down