fix: use process.argv to get raw args for cs-cloud to fix Linux hang issue
参考 opencode 实现,从 process.argv 重新获取原始参数,避免 commander 的 参数解析影响 cs-cloud 的正常运行。修复 Linux 上通过 csc cloud start 调用会卡住的问题。 Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
This commit is contained in:
parent
ecb0df50d3
commit
bf62a5e118
|
|
@ -222,6 +222,13 @@ async function ensureCsCloud(): Promise<string> {
|
|||
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> {
|
||||
const bin = await ensureCsCloud()
|
||||
const child = spawn(bin, args, {
|
||||
|
|
@ -240,20 +247,21 @@ async function runCsCloud(args: 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...]")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (rawArgs[0] === "upgrade") {
|
||||
if (args[0] === "upgrade") {
|
||||
const bin = csCloudBin()
|
||||
if (fs.existsSync(bin)) {
|
||||
await runCsCloud(rawArgs)
|
||||
await runCsCloud(args)
|
||||
return
|
||||
}
|
||||
await ensureCsCloud()
|
||||
return
|
||||
}
|
||||
|
||||
await runCsCloud(rawArgs)
|
||||
await runCsCloud(args)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user