First commit

This commit is contained in:
2026-01-12 13:12:46 +01:00
parent b2d9501f6d
commit a1fbd8acf5
4413 changed files with 1245183 additions and 0 deletions

30
node_modules/on-exit-leak-free/test/base.test.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
'use strict'
const { test } = require('tap')
const { fork } = require('child_process')
const { join } = require('path')
const { once } = require('events')
const { register } = require('..')
const files = [
'close.js',
'beforeExit',
'gc-not-close.js',
'unregister.js'
]
for (const file of files) {
test(file, async ({ equal }) => {
const child = fork(join(__dirname, 'fixtures', file), [], {
execArgv: ['--expose-gc']
})
const [code] = await once(child, 'close')
equal(code, 0)
})
}
test('undefined', async ({ throws }) => {
throws(() => register(undefined))
})

View File

@@ -0,0 +1,23 @@
'use strict'
const t = require('tap')
const { register, unregister } = require('..')
process.on('warning', () => {
t.fail('warning emitted')
})
const objs = []
for (let i = 0; i < 20; i++) {
const obj = { i }
objs.push(obj)
register(obj, shutdown)
}
for (const obj of objs) {
unregister(obj)
}
t.pass('completed')
function shutdown () {}

View File

@@ -0,0 +1,33 @@
'use strict'
const { unregister, registerBeforeExit } = require('../..')
const assert = require('assert')
function setup () {
const obj = { foo: 'bar' }
registerBeforeExit(obj, shutdown)
}
let shutdownCalled = false
let timeoutFinished = false
function shutdown (obj, event) {
shutdownCalled = true
if (event === 'beforeExit') {
setTimeout(function () {
timeoutFinished = true
assert.strictEqual(obj.foo, 'bar')
unregister(obj)
}, 100)
process.on('beforeExit', function () {
assert.strictEqual(timeoutFinished, true)
})
} else {
throw new Error('different event')
}
}
setup()
process.on('exit', function () {
assert.strictEqual(shutdownCalled, true)
})

21
node_modules/on-exit-leak-free/test/fixtures/close.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict'
const { register } = require('../..')
const assert = require('assert')
function setup () {
const obj = { foo: 'bar' }
register(obj, shutdown)
}
let shutdownCalled = false
function shutdown (obj) {
shutdownCalled = true
assert.strictEqual(obj.foo, 'bar')
}
setup()
process.on('exit', function () {
assert.strictEqual(shutdownCalled, true)
})

View File

@@ -0,0 +1,24 @@
'use strict'
const { register } = require('../..')
const assert = require('assert')
function setup () {
let obj = { foo: 'bar' }
register(obj, shutdown)
setImmediate(function () {
obj = undefined
gc() // eslint-disable-line
})
}
let shutdownCalled = false
function shutdown (obj) {
shutdownCalled = true
}
setup()
process.on('exit', function () {
assert.strictEqual(shutdownCalled, false)
})

View File

@@ -0,0 +1,24 @@
'use strict'
const { register, unregister } = require('../..')
const assert = require('assert')
function setup () {
const obj = { foo: 'bar' }
register(obj, shutdown)
setImmediate(function () {
unregister(obj)
unregister(obj) // twice, this should not throw
})
}
let shutdownCalled = false
function shutdown (obj) {
shutdownCalled = true
}
setup()
process.on('exit', function () {
assert.strictEqual(shutdownCalled, false)
})