fallow-core 3.32.0

Internal detector backend for fallow-engine and fallow-api
Documentation
//! A source string with a `node_modules/.bin/<name>` path runs or locates an
//! installed binary. The package that declares the binary is in use, so the
//! dependency is not unused. Fallow maps the binary name to a package with
//! the same map that the script analysis uses. A name that maps to no
//! declared dependency credits nothing and reports nothing.

use super::common::{create_config, fixture_path};

#[cfg_attr(miri, ignore)]
#[test]
fn node_modules_bin_path_credits_the_package_of_the_binary() {
    let root = fixture_path("node-modules-bin-path");
    let config = create_config(root);
    let results = fallow_core::analyze(&config).expect("analysis should succeed");

    let unused: Vec<&str> = results
        .unused_dependencies
        .iter()
        .map(|finding| finding.dep.package_name.as_str())
        .collect();
    assert_eq!(
        unused,
        ["idle-dep"],
        "a node_modules/.bin path credits the package that declares the binary"
    );
    assert!(
        results.unlisted_dependencies.is_empty(),
        "a binary name without a declared package reports no unlisted dependency"
    );
}