Skip to main content

run_script

Function run_script 

Source
pub async fn run_script(
    script_dir: &Path,
    project_root: &Path,
    modules_dir_name: &str,
    manifest: &PackageJson,
    script_name: &str,
    script_cmd: &str,
    extra_bin_dir: Option<&Path>,
) -> Result<(), Error>
Expand description

Run a single npm-style script line through sh -c with the usual environment ($PATH extended with node_modules/.bin, INIT_CWD, npm_lifecycle_event, npm_package_name, npm_package_version).

extra_bin_dir is an optional directory prepended to PATH before the project-level .bin. Dep lifecycle scripts pass the dep’s own sibling node_modules/.bin/ so transitive binaries (e.g. prebuild-install, node-gyp) declared in the dep’s dependencies are reachable. Root scripts pass None — their transitive bins are already hoisted into the project-level .bin.

Inherits stdio from the parent so the user sees script output live. Returns Err on non-zero exit so install fails fast if a lifecycle script breaks, matching pnpm.