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" `