Skip to content

Commit 9928a19

Browse files
committed
🤖 fix: make node-pty rebuild conditional on Electron presence
When installing mux via npm as a CLI tool, Electron is not present, causing the postinstall script to fail when trying to rebuild node-pty for Electron ABI. This change makes the rebuild conditional: - If Electron is installed (dev/packaged app): rebuild for Electron ABI - If Electron is not installed (npm CLI): use Node.js ABI (default) This allows mux to be installed both as an Electron app (with terminal support) and as a standalone CLI tool via npm. _Generated with `mux`_
1 parent 31680dd commit 9928a19

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"access": "public"
1717
},
1818
"scripts": {
19-
"postinstall": "npx @electron/rebuild -f -m node_modules/node-pty",
19+
"postinstall": "./scripts/postinstall.sh",
2020
"dev": "make dev",
2121
"prebuild:main": "./scripts/generate-version.sh",
2222
"build": "make build",
@@ -171,6 +171,7 @@
171171
"dist/**/*.json",
172172
"dist/**/*.png",
173173
"dist/assets/**/*",
174+
"scripts/postinstall.sh",
174175
"README.md",
175176
"LICENSE"
176177
],

scripts/postinstall.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Only rebuild node-pty for Electron if Electron is installed (for dev or packaged app usage)
5+
# For npm CLI installs, node-pty will use its default Node.js ABI which works fine
6+
if [ -d "node_modules/electron" ]; then
7+
echo "Electron detected - rebuilding node-pty for Electron ABI..."
8+
9+
# Use bun x or npx depending on what's available
10+
if command -v bun &>/dev/null; then
11+
bun x @electron/rebuild -f -m node_modules/node-pty
12+
elif command -v npx &>/dev/null; then
13+
npx @electron/rebuild -f -m node_modules/node-pty
14+
else
15+
echo "Warning: Neither bun nor npx found, skipping rebuild"
16+
echo "node-pty may not work correctly in Electron"
17+
fi
18+
else
19+
echo "Electron not detected - using node-pty with Node.js ABI (CLI mode)"
20+
fi

0 commit comments

Comments
 (0)