mirror of https://github.com/garrytan/gstack.git
Merge a81da822c1 into 2be6c06ba8
This commit is contained in:
commit
e87ef5ee0f
|
|
@ -146,6 +146,10 @@ function hashPath(p: string): string {
|
||||||
* call share one fork-exec (~200ms saved per skill preamble).
|
* call share one fork-exec (~200ms saved per skill preamble).
|
||||||
*/
|
*/
|
||||||
const _gbrainBinCache = new Map<string, string | null>();
|
const _gbrainBinCache = new Map<string, string | null>();
|
||||||
|
// On Windows the shim is `gbrain.cmd` → `bun run cli.ts`; a cold spawn can
|
||||||
|
// exceed 2s, and a false negative here poisons the 60s status cache with
|
||||||
|
// "no-cli". Give the shim headroom; POSIX keeps the tight timeout.
|
||||||
|
const VERSION_PROBE_TIMEOUT_MS = NEEDS_SHELL_ON_WINDOWS ? 10_000 : 2_000;
|
||||||
export function resolveGbrainBin(env?: NodeJS.ProcessEnv): string | null {
|
export function resolveGbrainBin(env?: NodeJS.ProcessEnv): string | null {
|
||||||
const e = env ?? process.env;
|
const e = env ?? process.env;
|
||||||
const key = e.PATH || "";
|
const key = e.PATH || "";
|
||||||
|
|
@ -154,7 +158,7 @@ export function resolveGbrainBin(env?: NodeJS.ProcessEnv): string | null {
|
||||||
try {
|
try {
|
||||||
execFileSync("gbrain", ["--version"], {
|
execFileSync("gbrain", ["--version"], {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
timeout: 2_000,
|
timeout: VERSION_PROBE_TIMEOUT_MS,
|
||||||
stdio: ["ignore", "ignore", "ignore"],
|
stdio: ["ignore", "ignore", "ignore"],
|
||||||
env: e,
|
env: e,
|
||||||
shell: NEEDS_SHELL_ON_WINDOWS, // #1731: gbrain is a .cmd shim on Windows
|
shell: NEEDS_SHELL_ON_WINDOWS, // #1731: gbrain is a .cmd shim on Windows
|
||||||
|
|
@ -177,7 +181,7 @@ export function readGbrainVersion(env?: NodeJS.ProcessEnv): string {
|
||||||
try {
|
try {
|
||||||
const out = execFileSync("gbrain", ["--version"], {
|
const out = execFileSync("gbrain", ["--version"], {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
timeout: 2_000,
|
timeout: VERSION_PROBE_TIMEOUT_MS,
|
||||||
stdio: ["ignore", "pipe", "ignore"],
|
stdio: ["ignore", "pipe", "ignore"],
|
||||||
env: e,
|
env: e,
|
||||||
shell: NEEDS_SHELL_ON_WINDOWS, // #1731: gbrain is a .cmd shim on Windows
|
shell: NEEDS_SHELL_ON_WINDOWS, // #1731: gbrain is a .cmd shim on Windows
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue