Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix(cli): normalize whichBinary output for Windows CRLF (PR #128 review)

Rohit Ghumaree2ee04ffa0f6
diff --git a/src/cli.ts b/src/cli.ts
index 0f3699e7..bd35f26e 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -88,7 +88,12 @@ function findIiiConfig(): string {
function whichBinary(name: string): string | null {
const cmd = IS_WINDOWS ? "where" : "which";
try {
- return execFileSync(cmd, [name], { encoding: "utf-8" }).trim().split("\n")[0];
+ const out = execFileSync(cmd, [name], { encoding: "utf-8" });
+ const first = out
+ .split(/\r?\n/)
+ .map((line) => line.trim())
+ .find((line) => line.length > 0);
+ return first ?? null;
} catch {
return null;
}