mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-19 16:13:56 +00:00
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
This commit is contained in:
parent
f2d1753d3a
commit
276b14adea
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
# <xbar.title>CodeBurn</xbar.title>
|
||||
# <xbar.version>v0.1.0</xbar.version>
|
||||
|
|
@ -81,7 +86,8 @@ function generatePlugin(bin: string): string {
|
|||
# <xbar.abouturl>https://github.com/agentseal/codeburn</xbar.abouturl>
|
||||
# <xbar.dependencies>node</xbar.dependencies>
|
||||
|
||||
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"
|
||||
`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue