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: add default cli flag #534

Merged
merged 2 commits into from
Jun 21, 2023
Merged

feat: add default cli flag #534

merged 2 commits into from
Jun 21, 2023

Conversation

nohehf
Copy link
Contributor

@nohehf nohehf commented Jun 13, 2023

This PR adds the --default=<default_pattern> flag to glob CLI.
It allows one to pass a default pattern that will be used if no positional argument is given.
This is especially useful when glob is aliased to some command. For instance, we can have in a package.json:

{
  [...],
  "scripts": {
    "test": "glob -c \"<test_command>\" --default \"./**/*.(spec|test).ts\""
    }
}

This allows one to pass a glob to select tests or run all tests if nothing is passed.
I currently use glob to pass files to our test command, hence the PR, but it likely has many other potential applications.
I intended to write a test, but looking at the codebase, I'm unsure if there is a way to test glob when used in CLI mode (via src/bin.ts). Please let me know if I'm wrong.

@isaacs
Copy link
Owner

isaacs commented Jun 13, 2023

Oh it looks like I forgot to check in the bin test. I'll fix that today.

Seems like --default would be a useful addition. 👍

@nohehf
Copy link
Contributor Author

nohehf commented Jun 17, 2023

Hey @isaacs any updates on this ? Thx!

@nohehf
Copy link
Contributor Author

nohehf commented Jun 22, 2023

Ty @isaacs :)

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.

2 participants