function borrowArgv
borrowArgv(argv: string[]): Disposable

Replaces process.argv for the scope and restores the previous value on exit.

import { borrowArgv } from './borrowed-globals.ts';

const before = process.argv;
{
  using _argv = borrowArgv(['node', 'cli.ts', '--watch']);
  process.argv[2]; // '--watch'
}
process.argv === before; // true — restored at the closing brace

Parameters

argv: string[]

Return Type

Disposable

Usage

import { borrowArgv } from "lib/utils/borrowed-globals.ts";