19 lines
525 B
TypeScript
19 lines
525 B
TypeScript
import { spawn } from 'node:child_process'
|
|
import { createBrowserInstallCommand } from './lib/browser-install.ts'
|
|
|
|
const { command, args } = createBrowserInstallCommand(process.argv.slice(2))
|
|
const child = spawn(command, args, { stdio: 'inherit' })
|
|
|
|
child.once('error', (error) => {
|
|
console.error(`无法启动 Chromium 安装程序:${error.message}`)
|
|
process.exitCode = 1
|
|
})
|
|
|
|
child.once('exit', (code, signal) => {
|
|
if (signal) {
|
|
process.kill(process.pid, signal)
|
|
return
|
|
}
|
|
process.exitCode = code ?? 1
|
|
})
|