Skip to content

Latest commit

 

History

History
52 lines (31 loc) · 2.29 KB

makeRunner.md

File metadata and controls

52 lines (31 loc) · 2.29 KB

@black-flag/coreDocs


@black-flag/core / util / makeRunner

Function: makeRunner()

makeRunner<CustomCliArguments>(options): <T>(...args) => Promise<NullArguments | Arguments<CustomCliArguments>>

A high-order factory function that returns a "low-order" runProgram function that can be called multiple times while only having to provide a subset of the required parameters at initialization.

This is useful when unit/integration testing your CLI, which will likely require multiple calls to runProgram(...).

Note: when an exception (e.g. bad arguments) occurs in the low-order function, undefined will be returned if configureProgram threw or NullArguments if execute threw. Otherwise, upon success, Arguments is returned as expected. That is: the promise returned by the low-order function will never reject and no exception will ever be thrown. Keep this in mind when writing your unit tests and see runProgram for more details.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

options: object & object | object

Returns

Function

Type Parameters

T extends [string] | [string, Promisable<ConfigurationHooks>] | [string, Promisable<PreExecutionContext>] | [string, string | string[]] | [string, string | string[], Promisable<ConfigurationHooks>] | [string, string | string[], Promisable<PreExecutionContext>]

Parameters

• ...args: T extends [_, ...Tail[]] ? Tail : []

Returns

Promise<NullArguments | Arguments<CustomCliArguments>>

Defined in

src/util.ts:51