Skip to main content

Toolbox

Trait Toolbox 

Source
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§

Source

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

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

Source

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

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

Source

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

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

Source

fn npx_available(&self) -> bool

Is npx itself available to provision packages on demand?

Implementors§