Skip to content

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!

@isaacs isaacs merged commit 1b2bc07 into isaacs:main Jun 21, 2023
@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