Skip to content

Replace Bun-specific APIs with Node.js child_process for compatibility - #32

Merged
brianlovin merged 4 commits into
mainfrom
claude/fix-bun-dependency-check-dl6Af
Jan 27, 2026
Merged

Replace Bun-specific APIs with Node.js child_process for compatibility#32
brianlovin merged 4 commits into
mainfrom
claude/fix-bun-dependency-check-dl6Af

Conversation

@brianlovin

Copy link
Copy Markdown
Owner

Summary

This PR replaces Bun-specific runtime APIs with standard Node.js APIs to improve compatibility and allow the CLI to run under different JavaScript runtimes. The changes maintain the same functionality while using cross-platform alternatives.

Key Changes

  • Added shell wrapper script (bin/hn): New executable shell script that checks for Bun installation and delegates to the compiled CLI, providing a better user experience with clear error messages if Bun is not available
  • Updated package.json: Changed the bin entry point from directly referencing the compiled CLI to using the new shell wrapper, and added bin directory to the files array for distribution
  • Replaced Bun.spawn() with node:child_process: Updated clipboard operations in src/app.ts and src/components/Header.ts to use the standard Node.js spawn() function instead of Bun-specific APIs
  • Improved error handling: Wrapped clipboard operations in Promises with proper event listeners for close and error events, ensuring graceful failure if clipboard commands are unavailable

Implementation Details

  • The shell wrapper provides helpful installation instructions if Bun is not found, improving the developer experience
  • The spawn() calls use the same clipboard commands (xclip/pbcopy) but with standard Node.js APIs
  • Error handling remains silent on failure, maintaining the original behavior where clipboard operations don't interrupt the application
  • The Promise-based approach ensures proper cleanup and resolution of child processes

https://claude.ai/code/session_019648v5yaArRCrsghuSW4SE

claude and others added 4 commits January 26, 2026 21:27
When users install via `npm install -g` without having Bun installed,
the CLI now shows a helpful error message with installation instructions
instead of failing silently or with a confusing error.

- Add bin/hn shell wrapper that checks for Bun before running
- Update package.json bin entry to use the wrapper
- Include bin directory in npm package files

https://claude.ai/code/session_019648v5yaArRCrsghuSW4SE
- Add shell wrapper that checks for Bun before running CLI
- Show clear error message with installation instructions when Bun is missing
- Explains that @opentui/core requires Bun runtime
- Replace Bun.spawn with node:child_process spawn (works in both runtimes)

Note: Full Node.js compatibility isn't possible because @opentui/core
uses bun:ffi for Yoga layout engine and tree-sitter bindings.

https://claude.ai/code/session_019648v5yaArRCrsghuSW4SE
This enables npm users to install the CLI without needing Bun installed
at runtime. The app is compiled to standalone executables for each platform.

Changes:
- bin/hn: Node.js launcher that finds and runs platform-specific binary
- script/build-binaries.ts: Cross-platform compilation script
- package.json: Added optionalDependencies for platform packages
- .github/workflows/publish.yml: Build and publish platform packages
- src/app.ts, src/components/Header.ts: Fixed TypeScript errors

Distribution model:
- npm install -g @brianlovin/hn-cli installs the launcher + platform binary
- Platform packages: @brianlovin/hn-cli-{darwin,linux,windows}-{arm64,x64}
- No Bun runtime required for end users

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The build script now updates optionalDependencies in package.json
to match the current version, ensuring platform package versions
stay in sync during releases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@brianlovin
brianlovin merged commit cc59b50 into main Jan 27, 2026
1 check passed
@brianlovin
brianlovin deleted the claude/fix-bun-dependency-check-dl6Af branch January 27, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants