fix(mac): keep pnpm health output json-safe
This commit is contained in:
@@ -99,10 +99,13 @@ final class HealthStore: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var env = ProcessInfo.processInfo.environment
|
||||||
|
env["PATH"] = CommandResolver.preferredPaths().joined(separator: ":")
|
||||||
|
|
||||||
let response = await ShellRunner.run(
|
let response = await ShellRunner.run(
|
||||||
command: CommandResolver.clawdisCommand(subcommand: "health", extraArgs: ["--json"]),
|
command: CommandResolver.clawdisCommand(subcommand: "health", extraArgs: ["--json"]),
|
||||||
cwd: nil,
|
cwd: CommandResolver.projectRootPath(),
|
||||||
env: nil,
|
env: env,
|
||||||
timeout: 15)
|
timeout: 15)
|
||||||
|
|
||||||
guard response.ok, let data = response.payload, !data.isEmpty else {
|
guard response.ok, let data = response.payload, !data.isEmpty else {
|
||||||
|
|||||||
@@ -250,7 +250,8 @@ enum CommandResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let pnpm = self.findExecutable(named: "pnpm") {
|
if let pnpm = self.findExecutable(named: "pnpm") {
|
||||||
return [pnpm, "clawdis", subcommand] + extraArgs
|
// Use --silent to avoid pnpm lifecycle banners that would corrupt JSON outputs.
|
||||||
|
return [pnpm, "--silent", "clawdis", subcommand] + extraArgs
|
||||||
}
|
}
|
||||||
return ["clawdis", subcommand] + extraArgs
|
return ["clawdis", subcommand] + extraArgs
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,20 @@ import Testing
|
|||||||
|
|
||||||
let cmd = CommandResolver.clawdisCommand(subcommand: "rpc")
|
let cmd = CommandResolver.clawdisCommand(subcommand: "rpc")
|
||||||
|
|
||||||
#expect(cmd.prefix(3).elementsEqual([pnpmPath.path, "clawdis", "rpc"]))
|
#expect(cmd.prefix(4).elementsEqual([pnpmPath.path, "--silent", "clawdis", "rpc"]))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func pnpmKeepsExtraArgsAfterSubcommand() async throws {
|
||||||
|
let tmp = try makeTempDir()
|
||||||
|
CommandResolver.setProjectRoot(tmp.path)
|
||||||
|
|
||||||
|
let pnpmPath = tmp.appendingPathComponent("node_modules/.bin/pnpm")
|
||||||
|
try makeExec(at: pnpmPath)
|
||||||
|
|
||||||
|
let cmd = CommandResolver.clawdisCommand(subcommand: "health", extraArgs: ["--json", "--timeout", "5"])
|
||||||
|
|
||||||
|
#expect(cmd.prefix(5).elementsEqual([pnpmPath.path, "--silent", "clawdis", "health", "--json"]))
|
||||||
|
#expect(cmd.suffix(2).elementsEqual(["--timeout", "5"]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func preferredPathsStartWithProjectNodeBins() async throws {
|
@Test func preferredPathsStartWithProjectNodeBins() async throws {
|
||||||
|
|||||||
Reference in New Issue
Block a user