Skip to main content

Toolbox

Trait Toolbox 

pub trait Toolbox {
    // Required methods
    fn on_path(&self, tool: &str) -> Option<PathBuf>;
    fn in_dir(&self, dir: &Path, tool: &str) -> Option<PathBuf>;
    fn version(&self, path: &Path) -> Option<Version>;
    fn npx_available(&self) -> bool;
}
Expand description

Abstraction over the host so detection is testable. The real implementation is SystemToolbox; tests supply a deterministic fake.

Required Methods§

fn on_path(&self, tool: &str) -> Option<PathBuf>

Resolve tool on the global PATH (with PATHEXT semantics).

fn in_dir(&self, dir: &Path, tool: &str) -> Option<PathBuf>

Resolve tool inside a specific directory (a node_modules/.bin).

fn version(&self, path: &Path) -> Option<Version>

Run <path> --version and parse the first version it prints.

fn npx_available(&self) -> bool

Is npx itself available to provision packages on demand?

Implementors§