30 lines
914 B
JavaScript
30 lines
914 B
JavaScript
import { spawnSync } from 'node:child_process'
|
|
|
|
const majorVersion = Number.parseInt(process.versions.node.split('.')[0] ?? '', 10)
|
|
if (!Number.isFinite(majorVersion) || majorVersion < 24) {
|
|
console.error(`test:all requires Node 24+, got ${process.version}`)
|
|
process.exit(1)
|
|
}
|
|
|
|
const npmCommand = process.env.npm_execpath
|
|
? process.execPath
|
|
: (process.platform === 'win32' ? 'npm.cmd' : 'npm')
|
|
|
|
for (const args of [
|
|
['run', 'test', '--', '--maxWorkers=2'],
|
|
['run', 'test:scripts'],
|
|
['run', 'test:agent'],
|
|
]) {
|
|
const spawnArgs = process.env.npm_execpath ? [process.env.npm_execpath, ...args] : args
|
|
const result = spawnSync(npmCommand, spawnArgs, {
|
|
stdio: 'inherit',
|
|
shell: !process.env.npm_execpath && process.platform === 'win32',
|
|
})
|
|
if (result.error) throw result.error
|
|
if (result.signal) {
|
|
process.exitCode = 1
|
|
break
|
|
}
|
|
if (result.status !== 0) process.exitCode = 1
|
|
}
|