Skip to content

Commit 0846ed7

Browse files
authored
Merge branch 'main' into pr-1310
2 parents 0d2a120 + 320b13c commit 0846ed7

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/steps/generic.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,9 +1569,25 @@ pub fn run_zvm(ctx: &ExecutionContext) -> Result<()> {
15691569
pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
15701570
let bun = require("bun")?;
15711571

1572-
print_separator("Bun");
1573-
1574-
ctx.execute(bun).arg("upgrade").status_checked()
1572+
// From the official install script (both install.sh and install.ps1), Bun uses
1573+
// the path set in this variable as the install root, and its defaults to
1574+
// `$HOME/.bun`
1575+
//
1576+
// UNIX: https://bun.sh/install.sh
1577+
// Windows: https://bun.sh/install.ps1
1578+
let bun_install_env = env::var("BUN_INSTALL")
1579+
.map(PathBuf::from)
1580+
.unwrap_or(HOME_DIR.join(".bun"));
1581+
1582+
// If `bun` is a descendant of `bun_install_env`, then Bun is installed
1583+
// through the official script
1584+
if bun.is_descendant_of(&bun_install_env) {
1585+
print_separator("Bun");
1586+
1587+
ctx.execute(bun).arg("upgrade").status_checked()
1588+
} else {
1589+
Err(SkipStep("Not installed through the official script".to_string()).into())
1590+
}
15751591
}
15761592

15771593
pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {

0 commit comments

Comments
 (0)