function swapBinary
swapBinary(
staged: string,
target: string,
platform?: NodeJS.Platform
): Promise<void>

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.

import * as Install from './install.ts';

// Defined, not invoked: renames files on disk.
async function swap() {
  await Install.swapBinary('/opt/qunitx/.staged/qunitx', '/opt/qunitx/qunitx', 'linux');
}

Parameters

staged: string
target: string
optional
platform: NodeJS.Platform = [process.platform]

Return Type

Promise<void>

Usage

import { swapBinary } from "lib/commands/upgrade/install.ts";