pub fn detect_runner(project_dir: &Path) -> RunnerExpand description
Detect the package manager for a project.
Detection priority:
packageManagerfield in package.json (e.g., “pnpm@8.0.0”)- Lock file detection:
bun.lockb→ Bunpnpm-lock.yaml→ pnpmyarn.lock→ Yarnpackage-lock.json→ npm
- Fallback to npm
§Arguments
project_dir- Path to the project directory
§Examples
use std::path::Path;
use npm_run_scripts::package::detect_runner;
let runner = detect_runner(Path::new("/path/to/project"));
println!("Using: {}", runner);