Skip to content

Commit 412965b

Browse files
authored
feat: support bun.lock for automatic package manager resolution (#119)
* Update install.rs to include bun.lock * add bun tests
1 parent 12ee731 commit 412965b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/install.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl PackageManager {
1818
pub fn resolve() -> Result<Self> {
1919
if fs::metadata("package-lock.json").is_ok() {
2020
return Ok(PackageManager::Npm);
21-
} else if fs::metadata("bun.lockb").is_ok() {
21+
} else if fs::metadata("bun.lockb").is_ok() || fs::metadata("bun.lock").is_ok() {
2222
return Ok(PackageManager::Bun);
2323
} else if fs::metadata("yarn.lock").is_ok() {
2424
return Ok(PackageManager::Yarn);
@@ -90,12 +90,20 @@ mod test {
9090

9191
fs::File::create("package-lock.json").unwrap();
9292
assert_eq!(PackageManager::resolve().unwrap(), PackageManager::Npm);
93-
9493
fs::remove_file("package-lock.json").unwrap();
94+
95+
fs::File::create("bun.lockb").unwrap();
96+
assert_eq!(PackageManager::resolve().unwrap(), PackageManager::Bun);
97+
fs::remove_file("bun.lockb").unwrap();
98+
99+
fs::File::create("bun.lock").unwrap();
100+
assert_eq!(PackageManager::resolve().unwrap(), PackageManager::Bun);
101+
fs::remove_file("bun.lock").unwrap();
102+
95103
fs::File::create("yarn.lock").unwrap();
96104
assert_eq!(PackageManager::resolve().unwrap(), PackageManager::Yarn);
97-
98105
fs::remove_file("yarn.lock").unwrap();
106+
99107
assert_eq!(PackageManager::resolve().unwrap(), PackageManager::Pnpm);
100108
}
101109

0 commit comments

Comments
 (0)