diff options
| author | Dax Raad <[email protected]> | 2025-06-10 11:06:01 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-06-10 11:06:01 -0400 |
| commit | fa7416687bfe67d47b187c5b9c0dc8a5d2a95781 (patch) | |
| tree | 59616ac75f4edec9ae6f0ab89db4e368d4f8c1e6 | |
| parent | c3ab370344cfcaba8396f32f8827e4dcaeca6fbc (diff) | |
| download | opencode-fa7416687bfe67d47b187c5b9c0dc8a5d2a95781.tar.gz opencode-fa7416687bfe67d47b187c5b9c0dc8a5d2a95781.zip | |
Enhance ripgrep error handling and utility functions
🤖 Generated with [OpenCode](https://opencode.ai)
Co-Authored-By: OpenCode <[email protected]>
| -rw-r--r-- | packages/opencode/src/ripgrep/index.ts | 27 | ||||
| -rw-r--r-- | packages/opencode/src/util/error.ts | 4 |
2 files changed, 15 insertions, 16 deletions
diff --git a/packages/opencode/src/ripgrep/index.ts b/packages/opencode/src/ripgrep/index.ts index 9e42262b8..d98e9f139 100644 --- a/packages/opencode/src/ripgrep/index.ts +++ b/packages/opencode/src/ripgrep/index.ts @@ -62,21 +62,16 @@ export namespace Ripgrep { const archivePath = path.join(Global.Path.bin, filename) await Bun.write(archivePath, buffer) if (config.extension === "tar.gz") { - const proc = Bun.spawn( - [ - "tar", - "-xzf", - archivePath, - "--strip-components=1", - "--wildcards", - "*/rg", - ], - { - cwd: Global.Path.bin, - stderr: "pipe", - stdout: "pipe", - }, - ) + const args = ["tar", "-xzf", archivePath, "--strip-components=1"] + + if (process.platform === "darwin") args.push("--include=*/rg") + if (process.platform === "linux") args.push("--wildcards", "*/rg") + + const proc = Bun.spawn(args, { + cwd: Global.Path.bin, + stderr: "pipe", + stdout: "pipe", + }) await proc.exited if (proc.exitCode !== 0) throw new ExtractionFailedError({ @@ -89,7 +84,7 @@ export namespace Ripgrep { ["unzip", "-j", archivePath, "*/rg.exe", "-d", Global.Path.bin], { cwd: Global.Path.bin, - stderr: "ignore", + stderr: "pipe", stdout: "ignore", }, ) diff --git a/packages/opencode/src/util/error.ts b/packages/opencode/src/util/error.ts index 3e3cf421d..7960fffb7 100644 --- a/packages/opencode/src/util/error.ts +++ b/packages/opencode/src/util/error.ts @@ -1,4 +1,7 @@ import { z, type ZodSchema } from "zod" +import { Log } from "./log" + +const log = Log.create() export abstract class NamedError extends Error { abstract schema(): ZodSchema @@ -24,6 +27,7 @@ export abstract class NamedError extends Error { ) { super(name, options) this.name = name + log.error(name, this.data) } static isInstance(input: any): input is InstanceType<typeof result> { |
