From 276b14adea8ece2f0bc2f5443233738083cf3430 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 17 Apr 2026 07:29:14 +0100 Subject: [PATCH] fix: prepend install-time node bin dir to menubar plugin PATH SwiftBar/xbar launch plugins with a minimal environment. If an older system Node (e.g. v18.x from Homebrew) appears earlier on PATH than the NVM-managed Node used to install codeburn, the plugin silently fails because string-width uses the /v regex flag (requires Node >= 20.11). Resolve the node binary directory at install time via process.execPath and prepend it to PATH in the generated plugin script. Also explicitly set HOME, which SwiftBar does not always inherit. Fixes #63 --- src/menubar.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/menubar.ts b/src/menubar.ts index a5abb5d..ca402a9 100644 --- a/src/menubar.ts +++ b/src/menubar.ts @@ -71,6 +71,11 @@ function getCodeburnBin(): string { function generatePlugin(bin: string): string { const home = homedir() + // Resolve the directory of the node binary used at install time so the + // plugin uses the same Node version codeburn was installed with — even + // when SwiftBar/xbar launch with a minimal PATH that finds an older + // system Node first. Fixes #63. + const nodeBinDir = join(process.execPath, '..') return `#!/bin/bash # CodeBurn # v0.1.0 @@ -81,7 +86,8 @@ function generatePlugin(bin: string): string { # https://github.com/agentseal/codeburn # node -export PATH="/usr/local/bin:/opt/homebrew/bin:$HOME/.local/bin:$HOME/.npm-global/bin:$PATH" +export HOME="${home}" +export PATH="${nodeBinDir}:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" ${bin} status --format menubar 2>/dev/null || echo "-- | sfimage=flame.fill" `