Skip to content

Function: resolveLazyCommand() ​

Resolve a lazy command to a Command.

If the loader returns a command, the properties of the loaded command take precedence, and the properties that it does not define fall back to the definition that is given to lazy. run comes from the loader only, as the definition has none. A loaded command without run is resolved without it, as any command without run, which the CLI fails with when it runs, unless it has sub-commands.

Signature ​

ts
export async function resolveLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: Commandable<G>, name?: string, needRunResolving: boolean = false): Promise<Command<G>>

Type Parameters ​

Name
G extends GunshiParamsConstraint = DefaultGunshiParams

Parameters ​

NameTypeDescription
cmdCommandable<G>A Commandable or LazyCommand to resolve
namestringOptional name of the command, if not provided, it will use the name from the command itself. (optional)
needRunResolvingbooleanWhether to run the loader of a lazy command. It runs on every call, as its result is not kept. (optional, default: false)

Returns ​

Promise<Command<G>> — A resolved Command, which is frozen

Released under the MIT License.