detect_package_managers

Function detect_package_managers 

Source
pub fn detect_package_managers(root: &Path) -> Result<Vec<PackageManager>>
Expand description

Detects all package managers present in the given directory.

This function scans for lockfiles and workspace configuration files, then returns a list of detected package managers ordered by confidence (highest first).

§Confidence scoring

  • Lockfile + valid workspace config: 100
  • Lockfile only: 75
  • Valid workspace config only: 50

§Examples

use cuenv_workspaces::detection::detect_package_managers;
use std::path::Path;

let managers = detect_package_managers(Path::new("/workspace"))?;
if !managers.is_empty() {
    println!("Primary package manager: {}", managers[0]);
}

§Errors

Returns an error if:

  • Directory cannot be accessed
  • Workspace config exists but is invalid