fix(cli): stop gram print from crashing when no browser opener is found #254

Merged
abiwab merged 1 commit from fix/open-in-browser-error into main 2026-11-25 17:46:49 +01:00
Owner

openInBrowser() returned true right after spawn(), but a missing opener (no xdg-open on Linux) fails afterwards, as an error event with no listener: gram print printed "Opening in browser…" and then crashed with a stack trace.

openInBrowser() now resolves to whether the opener started (spawn vs error event), so gram print shows its fallback message with the path of the file to open by hand. Checked on Bun and Node. The parameter is renamed target and takes an optional platform, for the test and for gram view --serve (dev/1.6), which opens a URL.

Tests: tests/printer.test.ts (missing opener resolves to false). Patch changeset included.

`openInBrowser()` returned `true` right after `spawn()`, but a missing opener (no `xdg-open` on Linux) fails afterwards, as an `error` event with no listener: `gram print` printed "Opening in browser…" and then crashed with a stack trace. `openInBrowser()` now resolves to whether the opener started (`spawn` vs `error` event), so `gram print` shows its fallback message with the path of the file to open by hand. Checked on Bun and Node. The parameter is renamed `target` and takes an optional `platform`, for the test and for `gram view --serve` (dev/1.6), which opens a URL. Tests: `tests/printer.test.ts` (missing opener resolves to false). Patch changeset included.
fix(cli): stop gram print from crashing when no browser opener is found
All checks were successful
CI / Build & Test (pull_request) Successful in 4m10s
6792a3ba6d
abiwab merged commit ab1ef119f6 into main 2026-11-25 17:46:49 +01:00
abiwab deleted branch fix/open-in-browser-error 2026-11-25 17:46:50 +01:00
Sign in to join this conversation.
No description provided.