detect_runner

Function detect_runner 

Source
pub fn detect_runner(project_dir: &Path) -> Runner
Expand description

Detect the package manager for a project.

Detection priority:

  1. packageManager field in package.json (e.g., “pnpm@8.0.0”)
  2. Lock file detection:
    • bun.lockb → Bun
    • pnpm-lock.yaml → pnpm
    • yarn.lock → Yarn
    • package-lock.json → npm
  3. 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);