Downloads the release archive, verifies it against the release's checksums.txt, and replaces
the running binary (and its esbuild sidecar, when the install has one).
Unpacks a release archive with the host's tar / unzip, falling back to PowerShell's
Expand-Archive where a Windows shell has no unzip — the same two-step jsr/cli.ts uses,
for the same reason: no JS extractor has to ship inside the binary.
Puts staged at target, honouring the one platform rule that matters: POSIX replaces a
running executable with an atomic rename (the running process keeps its inode), while Windows
cannot unlink a running image at all — so the old file is renamed aside first, and renamed back
if anything goes wrong.
The seams apply reaches the world through. All three default to the real thing.
-
access: (directory: string) => Promise<void>
Rejects when the install directory cannot be written. Defaults to
fs.access(dir, W_OK). -
extract: () => Promise<void>archivePath: string,destination: string
Unpacks the archive into a directory. Defaults to extract.
-
fetch: fetch
Fetches the checksum file and the archive.
What to install, and over what.
-
assetName: string
The archive to download from it.
-
binaryPath: string
The running executable to replace, and whose directory receives the sidecar.
-
platform: NodeJS.Platform
Path and replace semantics to apply. Defaults to the host's.
-
release: Release
The release to install, as Release
findreturned it.
The release has no asset for this platform — a deno compile build asking for a target only
the SEA matrix publishes, or the reverse.
The downloaded bytes do not hash to what the release published — a corrupted or truncated transfer, or a tampered asset. Nothing has been replaced when this is thrown.
The release publishes no checksums.txt, so the download cannot be verified. Refused rather
than downgraded to a warning: an unverified binary replacing the one you are running is
exactly the thing worth refusing.
The download itself failed — an HTTP error or a dead connection mid-transfer.
The replace itself failed, after the new binary was downloaded and verified. Carries the recovery path when the old binary had to be moved aside first.
The directory holding the binary is not writable by this user — the usual case being a
root-owned prefix such as /usr/local/bin.
Usage
import * as mod from "lib/commands/upgrade/install.ts";