To enhance the use of ni as part of other CLI packages, this extracts part of the run function into a separate getCliCommand function and exports it. This enables CLI authors such as myself to get a full CLI command, including the agent, without necessarily having to invoke it with execaCommand (which run does`).
await getCliCommand(parseNi, [name]) // e.g. "pnpm add vite"
My use case is that I need to invoke execaCommand myself, because I need to provide it with custom stdio config. I would also be happy with a execaOptions config option to enable this use case, but I imagine extracting getCliCommand enables more use cases / provides more flexibility and is thus more useful. I happen to use execa too, but others might not.
Additional context
I have not added any tests since I don't see any for the other top-level functions. Please advise on how/where to add any, if necessary.
Description
To enhance the use of
ni
as part of other CLI packages, this extracts part of therun
function into a separategetCliCommand
function and exports it. This enables CLI authors such as myself to get a full CLI command, including the agent, without necessarily having to invoke it withexecaCommand
(whichrun
does`).My use case is that I need to invoke
execaCommand
myself, because I need to provide it with customstdio
config. I would also be happy with aexecaOptions
config option to enable this use case, but I imagine extractinggetCliCommand
enables more use cases / provides more flexibility and is thus more useful. I happen to useexeca
too, but others might not.Additional context
I have not added any tests since I don't see any for the other top-level functions. Please advise on how/where to add any, if necessary.