Files
pnpm/jest.globalSetup.js
2024-07-25 16:45:47 +02:00

28 lines
686 B
JavaScript

const { start, prepare } = require('@pnpm/registry-mock')
module.exports = () => {
if (process.env.PNPM_REGISTRY_MOCK_PORT == null) return
prepare()
const server = start({
// Verdaccio stopped working properly on Node.js 22.
// You can test the issue by running:
// pnpm --filter=core run test test/install/auth.ts
useNodeVersion: '20.16.0',
stdio: 'inherit',
})
let killed = false
server.on('error', (err) => {
console.log(err)
})
server.on('close', () => {
if (!killed) {
console.log('Error: The registry server was killed!')
process.exit(1)
}
})
global.killServer = () => {
killed = true
server.kill()
}
}