Skip to content

Commit eec08a1

Browse files
authored
fix: use bun.lock to identify bun's lockfile (fix #12914) (#12998)
* fix: use bun.lock to identify bun's lockfile * fix: also check bun.lockb * doc: add changes doc
1 parent 35018ee commit eec08a1

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

.changes/fix-bun-lockfile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-cli': 'patch:bug'
3+
---
4+
5+
For bun's lockfile, check both `bun.lock` and `bun.lockb`.

crates/tauri-cli/src/helpers/npm.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,23 @@ impl PackageManager {
6767
for entry in entries.flatten() {
6868
let path = entry.path();
6969
let name = path.file_name().unwrap().to_string_lossy();
70-
if name.as_ref() == "package-lock.json" {
71-
found.push(PackageManager::Npm);
72-
} else if name.as_ref() == "pnpm-lock.yaml" {
73-
found.push(PackageManager::Pnpm);
74-
} else if name.as_ref() == "yarn.lock" {
75-
let yarn = if manager_version("yarn")
76-
.map(|v| v.chars().next().map(|c| c > '1').unwrap_or_default())
77-
.unwrap_or(false)
78-
{
79-
PackageManager::YarnBerry
80-
} else {
81-
PackageManager::Yarn
82-
};
83-
found.push(yarn);
84-
} else if name.as_ref() == "bun.lockb" {
85-
found.push(PackageManager::Bun);
86-
} else if name.as_ref() == "deno.lock" {
87-
found.push(PackageManager::Deno);
70+
match name.as_ref() {
71+
"package-lock.json" => found.push(PackageManager::Npm),
72+
"pnpm-lock.yaml" => found.push(PackageManager::Pnpm),
73+
"yarn.lock" => {
74+
let yarn = if manager_version("yarn")
75+
.map(|v| v.chars().next().map(|c| c > '1').unwrap_or_default())
76+
.unwrap_or(false)
77+
{
78+
PackageManager::YarnBerry
79+
} else {
80+
PackageManager::Yarn
81+
};
82+
found.push(yarn);
83+
}
84+
"bun.lock" | "bun.lockb" => found.push(PackageManager::Bun),
85+
"deno.lock" => found.push(PackageManager::Deno),
86+
_ => (),
8887
}
8988
}
9089
}

0 commit comments

Comments
 (0)