From 22af467944c466fd3b39f98c0ace713408522536 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Tue, 23 Jun 2026 14:26:12 -0700 Subject: [PATCH] slab deploy-status: resolve gh at absolute paths under launchd PATH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The menubar spawns the helper under launchd's minimal PATH, where gh isn't resolvable by name — so the gh-token fallback returned 'no GitHub token'. Look up gh at the usual Homebrew/.local paths like the wrapper does for node. --- slab/bin/deploy-status.mjs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/slab/bin/deploy-status.mjs b/slab/bin/deploy-status.mjs index 74fc66bd8c..765b026448 100755 --- a/slab/bin/deploy-status.mjs +++ b/slab/bin/deploy-status.mjs @@ -78,14 +78,33 @@ function writeStub() { } } +// Ask the GitHub CLI for a token. The menubar spawns us under launchd's +// minimal PATH (no Homebrew/fnm shims), so `gh` won't be on PATH — resolve it +// at the usual absolute locations, mirroring the wrapper's node lookup. +function ghToken() { + const candidates = [ + "gh", + "/opt/homebrew/bin/gh", + "/usr/local/bin/gh", + `${HOME}/.local/bin/gh`, + ]; + for (const bin of candidates) { + try { + const r = spawnSync(bin, ["auth", "token"], { encoding: "utf8" }); + if (r.status === 0 && r.stdout.trim()) return r.stdout.trim(); + } catch { + // try the next candidate + } + } + return null; +} + // Token precedence: config → env → `gh auth token` (CLI sign-in). function resolveToken(cfg) { if (cfg?.token && !/REPLACE_ME/.test(cfg.token)) return cfg.token; if (process.env.GH_TOKEN) return process.env.GH_TOKEN; if (process.env.GITHUB_TOKEN) return process.env.GITHUB_TOKEN; - const r = spawnSync("gh", ["auth", "token"], { encoding: "utf8" }); - if (r.status === 0) return r.stdout.trim(); - return null; + return ghToken(); } // ─── GitHub REST ─────────────────────────────────────────────────────────── -- 2.51.2