Files
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

52 lines
1.2 KiB
JavaScript

import { spawn, spawnSync } from 'node:child_process'
import { once } from 'node:events'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const tsxCommand = process.platform === 'win32' ? 'tsx.cmd' : 'tsx'
const cwd = resolve(dirname(fileURLToPath(import.meta.url)), '..')
function runBuild() {
const result = spawnSync(npmCommand, ['run', 'build'], {
cwd,
stdio: 'inherit',
})
if (result.status !== 0) {
process.exit(result.status ?? 1)
}
}
async function run() {
runBuild()
const server = spawn(tsxCommand, ['./server/index.mjs'], {
cwd,
stdio: 'inherit',
})
const stopServer = (signal) => {
if (server.exitCode === null) {
server.kill(signal)
}
}
process.on('SIGINT', () => stopServer('SIGINT'))
process.on('SIGTERM', () => stopServer('SIGTERM'))
const outcome = await Promise.race([
once(server, 'error').then(([error]) => {
throw error
}),
once(server, 'exit').then(([code]) => ({ code })),
])
process.exitCode = outcome.code ?? 0
}
run().catch((error) => {
console.error(error)
process.exitCode = 1
})