Merge pull request #108 from y574444354/fix/linux-cloud-hang

Fix/linux cloud hang
This commit is contained in:
DoSun 2026-05-15 14:56:48 +08:00 committed by GitHub
commit 4dc157e493
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -222,6 +222,13 @@ async function ensureCsCloud(): Promise<string> {
return bin return bin
} }
function getCloudRawArgs(): string[] {
const argv = process.argv.slice(2)
const index = argv.indexOf("cloud")
if (index === -1) return []
return argv.slice(index + 1)
}
async function runCsCloud(args: string[]): Promise<void> { async function runCsCloud(args: string[]): Promise<void> {
const bin = await ensureCsCloud() const bin = await ensureCsCloud()
const child = spawn(bin, args, { const child = spawn(bin, args, {
@ -240,20 +247,12 @@ async function runCsCloud(args: string[]): Promise<void> {
} }
export async function cloudHandler(rawArgs: string[]): Promise<void> { export async function cloudHandler(rawArgs: string[]): Promise<void> {
if (rawArgs.length === 0) { const args = getCloudRawArgs()
if (args.length === 0) {
console.error("specify a subcommand. usage: csc cloud <command> [args...]") console.error("specify a subcommand. usage: csc cloud <command> [args...]")
process.exit(1) process.exit(1)
} }
if (rawArgs[0] === "upgrade") { await ensureCsCloud()
const bin = csCloudBin() await runCsCloud(args)
if (fs.existsSync(bin)) {
await runCsCloud(rawArgs)
return
}
await ensureCsCloud()
return
}
await runCsCloud(rawArgs)
} }