mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 00:05:27 +00:00
fix(ecc2): detect bun.lock and npm-shrinkwrap.json lockfiles
The ECC 2 session launcher picked the package manager from lockfiles but only knew bun.lockb and package-lock.json. Bun 1.2+ writes the text bun.lock by default, so those projects fell through to npm. Match the Node detector in scripts/lib/package-manager.js, which already accepts bun.lock, bun.lockb, package-lock.json, and npm-shrinkwrap.json, while keeping the pnpm > bun > yarn > npm priority. Carries forward the lockfile-alias parity from #2998. Co-authored-by: mawquf28 <325559970+mawquf28@users.noreply.github.com>
This commit is contained in:
1 file changed
+23
@@ -3437,9 +3437,12 @@ fn read_package_manager_from_package_json(path: &Path) -> Option<&'static str> {
|
||||
fn detect_package_manager_from_lockfile(working_dir: &Path) -> Option<&'static str> {
|
||||
[
|
||||
("pnpm", "pnpm-lock.yaml"),
|
||||
// Bun 1.2+ writes the text bun.lock by default; keep the legacy binary lockfile.
|
||||
("bun", "bun.lock"),
|
||||
("bun", "bun.lockb"),
|
||||
("yarn", "yarn.lock"),
|
||||
("npm", "package-lock.json"),
|
||||
("npm", "npm-shrinkwrap.json"),
|
||||
]
|
||||
.into_iter()
|
||||
.find_map(|(package_manager, lockfile)| {
|
||||
@@ -4859,6 +4862,26 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detect_package_manager_from_lockfile_matches_node_lockfile_aliases() -> Result<()> {
|
||||
for (lockfile, expected) in [
|
||||
("bun.lock", "bun"),
|
||||
("bun.lockb", "bun"),
|
||||
("npm-shrinkwrap.json", "npm"),
|
||||
] {
|
||||
let tempdir = TestDir::new("manager-package-manager-lockfile-alias")?;
|
||||
let repo_root = tempdir.path().join("repo");
|
||||
fs::create_dir_all(&repo_root)?;
|
||||
fs::write(repo_root.join(lockfile), "lockfile\n")?;
|
||||
assert_eq!(
|
||||
detect_package_manager_from_lockfile(&repo_root),
|
||||
Some(expected),
|
||||
"{lockfile} should select {expected}"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_agent_command_prefers_project_package_manager_config_over_lockfile() -> Result<()> {
|
||||
let tempdir = TestDir::new("manager-package-manager-config")?;
|
||||
|
||||
Reference in new issue
Block a user