@black-flag/core • Docs
@black-flag/core / util / 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.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• options: object
& object
| object
Function
• T extends [string
] | [string
, Promisable
<ConfigurationHooks
>] | [string
, Promisable
<PreExecutionContext
>] | [string
, string
| string
[]] | [string
, string
| string
[], Promisable
<ConfigurationHooks
>] | [string
, string
| string
[], Promisable
<PreExecutionContext
>]
• ...args: T
extends [_
, ...Tail[]
] ? Tail
: []
Promise
<NullArguments
| Arguments
<CustomCliArguments
>>