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;

    // Provided method
    fn docker_daemon_running(&self, _path: &Path) -> 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?

Provided Methods§

Source

fn docker_daemon_running(&self, _path: &Path) -> bool

#3477: does the Docker CLI at path reach a running daemon (docker info succeeds)? Building a container image needs one. The default says yes, so a fake that does not model Docker is not made to fail.

Implementors§