IF Commons GitHub

observe

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-native-pinned-dialect FR-006, 0004-native-pinned-dialect FR-002

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"

Source: commons/archon-dialect-native-pinned/src/observe.ts

3 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

versionOffunction
function versionOf(text: string): string | undefined

The 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.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Asktypeno test imports it
type 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.

askWithinfunction
function askWithin(ms: number): Ask

An 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.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Observationtypeno test imports it
type 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 it
type ObserveOptions = {
  /** The PATH to look in. */
  readonly path: string | undefined;
  readonly ask: Ask;
};

What observeJob looks in and asks with.

observeJobfunction
function observeJob(job: ToolJob, store: Store, o: ObserveOptions): Promise<Observation>

What is observed of one tool: the store first, then the PATH.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.