versionOffunctionfunction versionOf(text: string): string | undefinedThe first version in a text (jq-1.7.1 and git version 2.43.0 give 1.7.1 and 2.43.0), or nothing.
What is installed: each tool is looked for in the store first (a copy whose install record is there and whose program is there too), then on the PATH under the program's name and each of its other names, and each program found on the PATH is asked its version with the tool's arguments under a limit of time. A program that cannot be asked (a hang, a crash, no version in what it says) is reported as found and unreadable and never ends the run. A tool that is in the store answers with no network and no write.
import { versionOf } from "./observe.ts";
versionOf("jq-1.7.1"); // "1.7.1"versionOffunctionfunction versionOf(text: string): string | undefinedThe first version in a text (jq-1.7.1 and git version 2.43.0 give 1.7.1 and 2.43.0), or nothing.
Asktypeno test imports ittype Ask = (argv: readonly string[]) => Promise<string | undefined>;Runs a program with the tool's arguments and gives what it said, or nothing where it could not be asked.
askWithinfunctionfunction askWithin(ms: number): AskAn Ask that gives a program ms milliseconds and then stops it; where a program has started others that keep its output open, the answer is still given at the limit and never waits for them.
Observationtypeno test imports ittype Observation = {
readonly seen: ObservedTool | undefined;
/** Where it was found: the program's path. */
readonly location: string | undefined;
/** Why a program that was found could not be read. */
readonly unreadable: string | undefined;
};What was found of one tool.
ObserveOptionstypeno test imports ittype ObserveOptions = {
/** The PATH to look in. */
readonly path: string | undefined;
readonly ask: Ask;
};What observeJob looks in and asks with.
observeJobfunctionfunction observeJob(job: ToolJob, store: Store, o: ObserveOptions): Promise<Observation>What is observed of one tool: the store first, then the PATH.