Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose getCliCommand function #164

Merged
merged 4 commits into from
Jul 18, 2023

Conversation

ghengeveld
Copy link
Contributor

@ghengeveld ghengeveld commented Jul 17, 2023

Description

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.

src/runner.ts Outdated Show resolved Hide resolved
@antfu antfu changed the title feat: Extract and expose getRunCommand function feat: expose getCliCommand function Jul 18, 2023
@antfu antfu merged commit 17d8eeb into antfu-collective:main Jul 18, 2023
2 checks passed
@ghengeveld ghengeveld deleted the get-run-command branch July 18, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants