MCPcopy Create free account
hub / github.com/garrytan/gstack / writeFakeGbrain

Function writeFakeGbrain

test/gstack-brain-context-load.test.ts:30–53  ·  view source on GitHub ↗
(binDir: string)

Source from the content-addressed store, hash-verified

28}
29
30function writeFakeGbrain(binDir: string): void {
31 if (process.platform === "win32") {
32 writeFileSync(
33 join(binDir, "gbrain.cmd"),
34 "@echo off\r\nif \"%1\"==\"--version\" (\r\n echo gbrain 0.test\r\n) else (\r\n echo fake gbrain %*\r\n)\r\n",
35 "utf-8",
36 );
37 return;
38 }
39
40 const fakeBin = join(binDir, "gbrain");
41 writeFileSync(
42 fakeBin,
43 `#!/bin/sh
44if [ "$1" = "--version" ]; then
45 echo "gbrain 0.test"
46else
47 echo "fake gbrain $*"
48fi
49`,
50 "utf-8",
51 );
52 chmodSync(fakeBin, 0o755);
53}
54
55function prependPath(binDir: string): Record<string, string> {
56 const pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === "path") || "PATH";

Calls

no outgoing calls

Tested by

no test coverage detected