mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-19 08:01:17 +00:00
fix: fall back to source-mode install when bundled build fails (#707)
bun 1.3.8 in Termux proot cannot resolve packages with --packages bundle even with bun.lock present and after --force reinstall. When the bundled build fails, install source + node_modules to ~/.spawn/ and create a wrapper script that runs via `bun` directly. Co-authored-by: Sprite <noreply@sprite.dev> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ac1f8239c8
commit
db72074e0a
2 changed files with 28 additions and 5 deletions
|
|
@ -163,16 +163,39 @@ build_and_install() {
|
|||
|
||||
cd "${tmpdir}/cli"
|
||||
bun install
|
||||
if ! bun run build; then
|
||||
|
||||
local build_ok=0
|
||||
if bun run build 2>/dev/null; then
|
||||
build_ok=1
|
||||
else
|
||||
log_warn "Build failed, retrying with forced reinstall..."
|
||||
bun install --force
|
||||
bun run build
|
||||
if bun run build 2>/dev/null; then
|
||||
build_ok=1
|
||||
fi
|
||||
fi
|
||||
|
||||
INSTALL_DIR="$(find_install_dir)"
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
cp cli.js "${INSTALL_DIR}/spawn"
|
||||
chmod +x "${INSTALL_DIR}/spawn"
|
||||
|
||||
if [ "$build_ok" = "1" ]; then
|
||||
cp cli.js "${INSTALL_DIR}/spawn"
|
||||
chmod +x "${INSTALL_DIR}/spawn"
|
||||
else
|
||||
# Bundled build failed — fall back to source mode.
|
||||
# Install source + node_modules to ~/.spawn/ and create a wrapper.
|
||||
log_warn "Bundled build unavailable, installing from source..."
|
||||
local spawn_lib="${HOME}/.spawn"
|
||||
rm -rf "${spawn_lib}"
|
||||
mkdir -p "${spawn_lib}"
|
||||
cp -r node_modules src package.json "${spawn_lib}/"
|
||||
cat > "${INSTALL_DIR}/spawn" <<'WRAPPER'
|
||||
#!/usr/bin/env bash
|
||||
exec bun "$HOME/.spawn/src/index.ts" "$@"
|
||||
WRAPPER
|
||||
chmod +x "${INSTALL_DIR}/spawn"
|
||||
fi
|
||||
|
||||
log_info "Installed spawn to ${INSTALL_DIR}/spawn"
|
||||
ensure_in_path "${INSTALL_DIR}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openrouter/spawn",
|
||||
"version": "0.2.60",
|
||||
"version": "0.2.61",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"spawn": "cli.js"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue