function spawn
spawn(argv: string[]): Promise<SpawnResult>

Runs another tool's installer — deno install, npm install -g — and reports how it went.

upgrade owns the standalone binary and replaces it itself. Every other user-level install is owned by the tool that made it, and the honest way to upgrade one is to ask that tool, which is what this does. The alternative, printing the line for someone to paste, is a worse version of the same command: it knows the answer and makes the user do it.

Stdio is inherited, so the installer's own progress and errors reach the terminal unfiltered. There is no shell: argv is passed through as given, so a version string can never be word-split or glob-expanded on its way to the installer.

Never rejects. A missing installer and a failing one are both answers about the upgrade rather than bugs in it, so both come back as a value the caller reports.

import * as Process from './process.ts';

// Defined, not invoked: spawns a real installer.
async function upgradeViaDeno() {
  const { exitCode, isMissingInstallerBinary } = await Process.spawn([
    'deno', 'install', '-Agf', 'jsr:@izelnakri/qunitx-cli@1.0.0',
  ]);
  return isMissingInstallerBinary ? 'deno is not installed' : `exited ${exitCode}`;
}

Parameters

argv: string[]

Return Type

Promise<SpawnResult>

Usage

import { spawn } from "lib/commands/upgrade/process.ts";