bvm-core 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/README.zh-CN.md +153 -0
- package/dist/bvm-shim.js +77 -0
- package/dist/bvm-shim.sh +65 -0
- package/dist/index.js +266 -0
- package/install.ps1 +202 -0
- package/install.sh +377 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# BVM — Bun Version Manager
|
|
2
|
+
|
|
3
|
+
BVM is a high-performance environment orchestrator designed for the Bun ecosystem. It leverages an **ArchSense (Self-Bootstrapping)** architecture, delivered via a **Global CDN (jsDelivr)** for instant availability. While providing a near-zero latency terminal experience, it maintains strict physical isolation between environments.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/EricLLLLLL/bvm/releases)
|
|
6
|
+
[](#)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
<a href="./README.zh-CN.md">🇨🇳 中文文档</a>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [About](#about)
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Install Script](#install-script)
|
|
18
|
+
- [Verify Installation](#verify-installation)
|
|
19
|
+
- [Manual Update](#manual-update)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Basic Commands](#basic-commands)
|
|
22
|
+
- [Running Commands](#running-commands)
|
|
23
|
+
- [Aliases](#aliases)
|
|
24
|
+
- [Configuration](#configuration)
|
|
25
|
+
- [.bvmrc](#bvmrc)
|
|
26
|
+
- [Design Philosophy](#design-philosophy)
|
|
27
|
+
- [ArchSense (Self-Bootstrapping)](#archsense-self-bootstrapping)
|
|
28
|
+
- [Smart Registry Racing](#smart-registry-racing)
|
|
29
|
+
- [Atomic Isolation](#atomic-isolation)
|
|
30
|
+
- [Technical Audit](#technical-audit)
|
|
31
|
+
- [Environment Variables](#environment-variables)
|
|
32
|
+
- [License](#license)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## About
|
|
37
|
+
|
|
38
|
+
BVM was engineered to solve the common pitfalls of traditional version managers: shell startup lag and environment leakage. By utilizing **NTFS Junctions/Unix Symlinks** and dynamic path injection, BVM ensures that your global packages and Bun runtimes remain perfectly isolated and instantly available.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
### Install Script
|
|
45
|
+
|
|
46
|
+
To install or update BVM, you should run the install script.
|
|
47
|
+
|
|
48
|
+
**macOS / Linux / WSL:**
|
|
49
|
+
```bash
|
|
50
|
+
curl -fsSL https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm@main/install.sh | bash
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Windows (Native PowerShell):**
|
|
54
|
+
```powershell
|
|
55
|
+
irm https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm@main/install.ps1 | iex
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Verify Installation
|
|
59
|
+
|
|
60
|
+
To verify that BVM has been installed correctly, open a new terminal and run:
|
|
61
|
+
```bash
|
|
62
|
+
bvm --version
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Manual Update
|
|
66
|
+
|
|
67
|
+
If you already have BVM installed, you can upgrade to the latest version using the built-in command:
|
|
68
|
+
```bash
|
|
69
|
+
bvm upgrade
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
### Basic Commands
|
|
77
|
+
|
|
78
|
+
* `bvm install latest`: Install the latest stable version of Bun.
|
|
79
|
+
* `bvm install 1.1.0`: Install a specific version.
|
|
80
|
+
* `bvm use 1.1.0`: Switch the active Bun version immediately.
|
|
81
|
+
* `bvm default 1.1.0`: Set a global default version for new shell sessions.
|
|
82
|
+
* `bvm ls`: List all locally installed versions.
|
|
83
|
+
* `bvm ls-remote`: List all available versions from the registry.
|
|
84
|
+
* `bvm uninstall 1.1.0`: Remove a specific version.
|
|
85
|
+
|
|
86
|
+
### Running Commands
|
|
87
|
+
|
|
88
|
+
You can run a command with a specific Bun version without switching your global environment:
|
|
89
|
+
```bash
|
|
90
|
+
bvm run 1.0.30 index.ts
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Aliases
|
|
94
|
+
|
|
95
|
+
Create custom names for specific versions:
|
|
96
|
+
```bash
|
|
97
|
+
bvm alias prod 1.1.0
|
|
98
|
+
bvm use prod
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
### .bvmrc
|
|
106
|
+
|
|
107
|
+
BVM supports automatic version switching via `.bvmrc` files. Create a file named `.bvmrc` in your project root containing the version number:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
echo "1.1.0" > .bvmrc
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Once configured, any `bun` command executed within that directory (or its subdirectories) will automatically use the specified version.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Design Philosophy
|
|
118
|
+
|
|
119
|
+
### ArchSense (Self-Bootstrapping)
|
|
120
|
+
BVM does not ship with heavy pre-compiled binaries. Instead, it uses **Bun to manage Bun**. The installer downloads a minimal Bun runtime to serve as BVM's execution engine, ensuring the manager itself is always running on the most optimized environment.
|
|
121
|
+
|
|
122
|
+
### Smart Registry Racing
|
|
123
|
+
BVM eliminates the need for manual mirror configuration. It identifies your location via Cloudflare Trace and concurrently "races" multiple registries (Official NPM, Taobao, Tencent) to pick the lowest-latency endpoint for your current network.
|
|
124
|
+
|
|
125
|
+
### Atomic Isolation
|
|
126
|
+
Unlike managers that only switch the `PATH`, BVM performs **Filesystem-level Locking**. It dynamically injects a unique `BUN_INSTALL` path for every version, ensuring that global packages installed in one version never conflict with another.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Technical Audit
|
|
131
|
+
|
|
132
|
+
| Metric | **BVM** | **bum** | **nvm** |
|
|
133
|
+
| :--- | :--- | :--- | :--- |
|
|
134
|
+
| **Shell Init Overhead** | **~9ms (Near-Zero)** | < 5ms | ~500ms (Blocking) |
|
|
135
|
+
| **Shim Latency** | **~8ms (Pure Bash/JS)** | ~20ms | ~100ms (Func Trap) |
|
|
136
|
+
| **Core Footprint** | **~50 KB (JS)** | ~5 MB (Binary) | ~100 KB (Scripts) |
|
|
137
|
+
| **Windows Support** | **Native Junctions** | Partial | No (WSL Only) |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Environment Variables
|
|
142
|
+
|
|
143
|
+
BVM respects the following environment variables:
|
|
144
|
+
|
|
145
|
+
* `BVM_DIR`: The directory where BVM stores its data (Default: `~/.bvm`).
|
|
146
|
+
* `BVM_REGISTRY`: Force a specific NPM registry for downloads.
|
|
147
|
+
* `BVM_MIRROR`: (Legacy) Fallback mirror URL.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT © [EricLLLLLL](https://github.com/EricLLLLLL)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# BVM — Bun 版本管理器
|
|
2
|
+
|
|
3
|
+
BVM 是为 Bun 生态量身定制的高性能环境编排工具。它采用 **ArchSense (架构自举)** 设计哲学,利用 Bun 驱动自身,并通过 **全球 CDN (jsDelivr)** 极速分发。在提供近乎零延迟的终端启动体验的同时,实现了物理级的环境原子隔离。
|
|
4
|
+
|
|
5
|
+
[](https://github.com/EricLLLLLL/bvm/releases)
|
|
6
|
+
[](#)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
<a href="./README.md">🇺🇸 English Docs</a>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 目录 (Table of Contents)
|
|
14
|
+
|
|
15
|
+
- [关于项目](#关于项目)
|
|
16
|
+
- [安装指南](#安装指南)
|
|
17
|
+
- [安装脚本](#安装脚本)
|
|
18
|
+
- [验证安装](#验证安装)
|
|
19
|
+
- [手动更新](#手动更新)
|
|
20
|
+
- [基本用法](#基本用法)
|
|
21
|
+
- [常用命令](#常用命令)
|
|
22
|
+
- [执行命令](#执行命令)
|
|
23
|
+
- [别名管理](#别名管理)
|
|
24
|
+
- [项目配置](#项目配置)
|
|
25
|
+
- [.bvmrc](#bvmrc)
|
|
26
|
+
- [设计哲学](#设计哲学)
|
|
27
|
+
- [ArchSense (架构自举)](#archsense-架构自举)
|
|
28
|
+
- [智能镜像竞速](#智能镜像竞速)
|
|
29
|
+
- [原子化隔离](#原子化隔离)
|
|
30
|
+
- [技术审计 (竞品对比)](#技术审计-架构级优势)
|
|
31
|
+
- [环境变量](#环境变量)
|
|
32
|
+
- [开源协议](#开源协议)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 关于项目
|
|
37
|
+
|
|
38
|
+
BVM 旨在解决传统版本管理器常见的两大痛点:终端启动延迟和环境泄漏。通过利用 **NTFS 联接点 (Junctions) / Unix 软链接** 以及动态路径注入技术,BVM 确保了全球包和 Bun 运行时在物理上的完全隔离,并实现了无感的启动速度。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 安装指南
|
|
43
|
+
|
|
44
|
+
### 安装脚本
|
|
45
|
+
|
|
46
|
+
运行以下命令即可完成安装或更新。
|
|
47
|
+
|
|
48
|
+
**macOS / Linux / WSL:**
|
|
49
|
+
```bash
|
|
50
|
+
curl -fsSL https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm@main/install.sh | bash
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Windows (原生 PowerShell):**
|
|
54
|
+
```powershell
|
|
55
|
+
irm https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm@main/install.ps1 | iex
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 验证安装
|
|
59
|
+
|
|
60
|
+
要验证 BVM 是否安装成功,请打开新终端并运行:
|
|
61
|
+
```bash
|
|
62
|
+
bvm --version
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 手动更新
|
|
66
|
+
|
|
67
|
+
如果您已经安装了 BVM,可以使用内置命令一键升级到最新版:
|
|
68
|
+
```bash
|
|
69
|
+
bvm upgrade
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 基本用法
|
|
75
|
+
|
|
76
|
+
### 常用命令
|
|
77
|
+
|
|
78
|
+
* `bvm install latest`: 安装最新的稳定版 Bun。
|
|
79
|
+
* `bvm install 1.1.0`: 安装指定版本。
|
|
80
|
+
* `bvm use 1.1.0`: 立即切换活跃的 Bun 版本。
|
|
81
|
+
* `bvm default 1.1.0`: 设置全局默认版本(新窗口生效)。
|
|
82
|
+
* `bvm ls`: 列出本地已安装的所有版本。
|
|
83
|
+
* `bvm ls-remote`: 列出注册表上可用的所有版本。
|
|
84
|
+
* `bvm uninstall 1.1.0`: 卸载指定版本。
|
|
85
|
+
|
|
86
|
+
### 执行命令
|
|
87
|
+
|
|
88
|
+
您可以在不切换全局环境的情况下,使用特定版本运行命令:
|
|
89
|
+
```bash
|
|
90
|
+
bvm run 1.0.30 index.ts
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 别名管理
|
|
94
|
+
|
|
95
|
+
为特定版本创建自定义名称:
|
|
96
|
+
```bash
|
|
97
|
+
bvm alias prod 1.1.0
|
|
98
|
+
bvm use prod
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 项目配置
|
|
104
|
+
|
|
105
|
+
### .bvmrc
|
|
106
|
+
|
|
107
|
+
BVM 支持通过 `.bvmrc` 文件自动切换版本。在项目根目录下创建一个包含版本号的文件:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
echo "1.1.0" > .bvmrc
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
配置完成后,在该目录(及其子目录)下执行任何 `bun` 命令,系统都将自动识别并应用指定版本。
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 设计哲学
|
|
118
|
+
|
|
119
|
+
### ArchSense (架构自举)
|
|
120
|
+
BVM 不分发沉重的预编译二进制文件。相反,它利用 **Bun 管理 Bun**。安装程序会首先下载一个极简的 Bun 运行时作为 BVM 的执行引擎,确保管理器自身始终运行在最优化的环境中。
|
|
121
|
+
|
|
122
|
+
### 智能镜像竞速
|
|
123
|
+
BVM 彻底消除了手动配置镜像的烦恼。它通过 Cloudflare Trace 识别地理位置,并同时对多个注册表(官方 NPM、淘宝、腾讯)发起“竞速”,自动为您选择当前网络下延迟最低的节点。
|
|
124
|
+
|
|
125
|
+
### 原子化隔离
|
|
126
|
+
不同于仅切换 `PATH` 的管理器,BVM 实现了 **文件系统级锁定**。它在执行命令前动态注入唯一的 `BUN_INSTALL` 路径,确保不同版本间安装的全局包永不冲突。
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 技术审计 (架构级优势)
|
|
131
|
+
|
|
132
|
+
| 审计维度 | **BVM** (本项目) | **bum** (Rust版) | **nvm** (Shell版) |
|
|
133
|
+
| :--- | :--- | :--- | :--- |
|
|
134
|
+
| **终端初始化开销** | **~9ms (极低损耗)** | < 5ms | ~500ms (明显卡顿) |
|
|
135
|
+
| **转发器运行时损耗** | **~8ms (内核转发)** | ~20ms | ~100ms (Shell函数) |
|
|
136
|
+
| **核心逻辑体积** | **~50 KB (JS)** | ~5 MB | ~100 KB |
|
|
137
|
+
| **Windows 适配** | **原生 Junctions** | 部分支持 | 不原生支持 |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 环境变量
|
|
142
|
+
|
|
143
|
+
BVM 支持以下环境变量配置:
|
|
144
|
+
|
|
145
|
+
* `BVM_DIR`: BVM 数据存储目录(默认:`~/.bvm`)。
|
|
146
|
+
* `BVM_REGISTRY`: 强制指定用于下载的 NPM 注册表。
|
|
147
|
+
* `BVM_MIRROR`: (旧版兼容) 镜像源地址。
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 开源协议
|
|
152
|
+
|
|
153
|
+
MIT © [EricLLLLLL](https://github.com/EricLLLLLL)
|
package/dist/bvm-shim.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* BVM Shim for Windows (JavaScript version)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const BVM_DIR = process.env.BVM_DIR || path.join(os.homedir(), '.bvm');
|
|
11
|
+
const CMD = process.argv[2] ? process.argv[2].replace(/\.exe$/i, '').replace(/\.cmd$/i, '') : 'bun';
|
|
12
|
+
const ARGS = process.argv.slice(3);
|
|
13
|
+
|
|
14
|
+
function resolveVersion() {
|
|
15
|
+
if (process.env.BVM_ACTIVE_VERSION) {
|
|
16
|
+
const v = process.env.BVM_ACTIVE_VERSION.trim();
|
|
17
|
+
return v.startsWith('v') ? v : 'v' + v;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let dir = process.cwd();
|
|
21
|
+
try {
|
|
22
|
+
const { root } = path.parse(dir);
|
|
23
|
+
while (true) {
|
|
24
|
+
const rc = path.join(dir, '.bvmrc');
|
|
25
|
+
if (fs.existsSync(rc)) {
|
|
26
|
+
const v = fs.readFileSync(rc, 'utf8').trim().replace(/^v/, '');
|
|
27
|
+
if (v) return 'v' + v;
|
|
28
|
+
}
|
|
29
|
+
if (dir === root) break;
|
|
30
|
+
dir = path.dirname(dir);
|
|
31
|
+
}
|
|
32
|
+
} catch(e) {}
|
|
33
|
+
|
|
34
|
+
const current = path.join(BVM_DIR, 'current');
|
|
35
|
+
if (fs.existsSync(current)) {
|
|
36
|
+
try {
|
|
37
|
+
const target = fs.realpathSync(current);
|
|
38
|
+
const v = path.basename(target);
|
|
39
|
+
if (v && v.startsWith('v')) return v;
|
|
40
|
+
} catch(e) {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const def = path.join(BVM_DIR, 'aliases', 'default');
|
|
44
|
+
if (fs.existsSync(def)) {
|
|
45
|
+
try {
|
|
46
|
+
const v = fs.readFileSync(def, 'utf8').trim().replace(/^v/, '');
|
|
47
|
+
if (v) return 'v' + v;
|
|
48
|
+
} catch(e) {}
|
|
49
|
+
}
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Simple synchronous execution for performance
|
|
54
|
+
const version = resolveVersion();
|
|
55
|
+
if (!version) {
|
|
56
|
+
console.error("BVM Error: No Bun version is active or default is set.");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const versionDir = path.join(BVM_DIR, 'versions', version);
|
|
61
|
+
const binDir = path.join(versionDir, 'bin');
|
|
62
|
+
const realExecutable = path.join(binDir, CMD + '.exe');
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(realExecutable)) {
|
|
65
|
+
console.error("BVM Error: Command '" + CMD + "' not found in Bun " + version + " at " + realExecutable);
|
|
66
|
+
process.exit(127);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
process.env.BUN_INSTALL = versionDir;
|
|
70
|
+
process.env.PATH = binDir + path.delimiter + process.env.PATH;
|
|
71
|
+
|
|
72
|
+
const child = spawn(realExecutable, ARGS, { stdio: 'inherit', shell: false });
|
|
73
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
|
74
|
+
child.on('error', (err) => {
|
|
75
|
+
console.error("BVM Error: Failed to start child process: " + err.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/dist/bvm-shim.sh
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Shim managed by BVM (Bun Version Manager)
|
|
3
|
+
# Optimized for performance via Bash-native syntax.
|
|
4
|
+
|
|
5
|
+
BVM_DIR="${BVM_DIR:-$HOME/.bvm}"
|
|
6
|
+
CMD_NAME="$1"
|
|
7
|
+
shift
|
|
8
|
+
|
|
9
|
+
if [ -z "$CMD_NAME" ]; then
|
|
10
|
+
echo "BVM Error: No command specified." >&2
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
# --- 1. Fast Path: Active Version or Local .bvmrc ---
|
|
15
|
+
if [ -n "$BVM_ACTIVE_VERSION" ]; then
|
|
16
|
+
VERSION="$BVM_ACTIVE_VERSION"
|
|
17
|
+
elif [ -f ".bvmrc" ]; then
|
|
18
|
+
# Read first line, strip whitespace and 'v' prefix using pure Bash
|
|
19
|
+
read -r raw_ver < .bvmrc
|
|
20
|
+
VERSION="v${raw_ver//[v[:space:]]/}"
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# --- 2. Slow Path: Recursive .bvmrc Search or Default ---
|
|
24
|
+
if [ -z "$VERSION" ]; then
|
|
25
|
+
CUR_DIR="$PWD"
|
|
26
|
+
while [ "$CUR_DIR" != "/" ] && [ -n "$CUR_DIR" ]; do
|
|
27
|
+
if [ -f "$CUR_DIR/.bvmrc" ]; then
|
|
28
|
+
read -r raw_ver < "$CUR_DIR/.bvmrc"
|
|
29
|
+
VERSION="v${raw_ver//[v[:space:]]/}"
|
|
30
|
+
break
|
|
31
|
+
fi
|
|
32
|
+
CUR_DIR=$(dirname "$CUR_DIR")
|
|
33
|
+
done
|
|
34
|
+
|
|
35
|
+
# Fallback to current symlink (most common production case)
|
|
36
|
+
if [ -z "$VERSION" ] && [ -L "$BVM_DIR/current" ]; then
|
|
37
|
+
VERSION_PATH=$(readlink "$BVM_DIR/current")
|
|
38
|
+
VERSION="${VERSION_PATH##*/}"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Fallback to default alias
|
|
42
|
+
if [ -z "$VERSION" ] && [ -f "$BVM_DIR/aliases/default" ]; then
|
|
43
|
+
read -r raw_ver < "$BVM_DIR/aliases/default"
|
|
44
|
+
VERSION="${raw_ver//[[:space:]]/}"
|
|
45
|
+
fi
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ -z "$VERSION" ]; then
|
|
49
|
+
echo "BVM Error: No Bun version active." >&2
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Ensure 'v' prefix
|
|
54
|
+
[[ "$VERSION" != v* ]] && VERSION="v$VERSION"
|
|
55
|
+
VERSION_DIR="$BVM_DIR/versions/$VERSION"
|
|
56
|
+
REAL_EXECUTABLE="$VERSION_DIR/bin/$CMD_NAME"
|
|
57
|
+
|
|
58
|
+
if [ -x "$REAL_EXECUTABLE" ]; then
|
|
59
|
+
export BUN_INSTALL="$VERSION_DIR"
|
|
60
|
+
export PATH="$VERSION_DIR/bin:$PATH"
|
|
61
|
+
exec "$REAL_EXECUTABLE" "$@"
|
|
62
|
+
else
|
|
63
|
+
echo "BVM Error: Command '$CMD_NAME' not found in Bun $VERSION." >&2
|
|
64
|
+
exit 127
|
|
65
|
+
fi
|