Skip to main content

Module probe

Module probe 

Source
Expand description

The shared detection probe: presence + version + provenance.

This generalises bynkc’s old tool_exists (which shelled the POSIX which and conceded it was Unix-only). Detection is backed by the which crate, which handles PATHEXT/where on Windows, so a user-facing environment check tells the truth on every platform (v0.46 portability decision).

Lookups go through a Toolbox so the capability/exit matrix and the output goldens can run against a deterministic fake instead of the host.

Structs§

DetectOpts
How a detection should look: where to search, and whether npx fetch-on-demand counts as a (provisionable) fallback. node itself is never allow_npx — you cannot npx a runtime.
Probe
One detection result: a tool, its version (if installed and it reports one), and where it came from.
SystemToolbox
The real host: which-crate lookups and a --version shell-out.
Version
A parsed tool version. Missing components default to zero, so "v18" parses as 18.0.0 and compares sensibly against a major-version floor.

Enums§

Provenance
Where a tool was found — the provenance half of a probe. The distinction between Provenance::Path/Provenance::ProjectLocal (installed) and Provenance::Npx (fetchable on demand) is the whole point: npx --yes will download a package at first use, so it must never read as a green “ok”.

Traits§

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

Functions§

detect
Detect a single tool: project-local first (it wins over a global install), then PATH, then — only if allow_npx — an npx provisionable fallback, else missing.