IF Commons GitHub

sql/cli/files

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0047-arcactl-init FR-003

Changing a person's file safely (commons data 0047-arcactl-init FR-003): a change is planned first, as a value that says what the file is now, what it would be and the difference, and is applied only where the person agreed. Applying it writes a temporary file beside the target and renames it over, so that a failure leaves the old file; keeps the file's mode (a new file gets the mode asked for, 0600 for a password file); keeps a copy of what the file was the first time it is changed; and, where the file is a symbolic link (a dotfile manager's), writes through it to the file it points at and says so. Where there is nothing to change it writes nothing.

Source: commons/data/sql/cli/files.ts

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

Actiontypeno test imports it
type Action = "create" | "update" | "unchanged" | "remove";

What a planned change does to a file.

diffOffunction
function diffOf(before: string | undefined, after: string): string

The difference between two texts as lines, - for a line that goes and + for one that comes (a line common to both is left out, with a line of context kept around a change).

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

FileErrortypeno test imports it
type FileError = { readonly kind: "block"; readonly path: string; readonly error: BlockError } | { readonly kind: "unreadable"; readonly path: string; readonly why: string };

What is wrong with a change.

pgpassModeOkconst
const pgpassModeOk: (mode: number) => boolean

Whether a password file's mode is one that libpq will use: it ignores a file that the group or others can read.

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

planBlockfunction
function planBlock(path: string, name: string, style: Style, want: Want, mode?: number): Result<Change, FileError>

Plans the change of one file for a block.

ParameterWhat it is
paththe file
namethe block's name
stylethe file's comment mark
wantthe body to put in, or absent to take the block out
modethe mode of a file that is made new

Returns: the change, or why it cannot be planned

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

Wanttypeno test imports it
type Want = { readonly body: string } | "absent";

What is wanted of a block: put in with a body, or taken out.

planRemoveFilefunctionno test imports it
function planRemoveFile(path: string): Result<Change, FileError>

Plans removing a file that arcactl owns whole: nothing where it is not there. A directory is refused.

planWholefunctionno test imports it
function planWhole(path: string, text: string, mode?: number): Result<Change, FileError>

Plans the change of a file that arcactl owns whole (its state, its cache): the file is the text, or is made.

ParameterWhat it is
paththe file
textwhat the file is to hold
modethe mode of a file that is made new

Returns: the change

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