Description
openedon Mar 6, 2019
Describe the user story
I'm a Yarn user and want to use glob patterns in my scripts. For example:
{
"scripts": {
"grep": "grep -F \"$1\" packages/*/sources"
}
}
Describe the solution you'd like
The shell should support a glob syntax (at least *
and **
).
Describe the drawbacks of your solution
Writing a good globing mechanism is difficult. The simplest would be to reuse an existing library such as glob
, but I wonder how that would fit in the cross-platform story.
Describe alternatives you've considered
We simply could decide not to add support for glob patterns, and let users be more explicit when they wish to use them (grep -F \"$1\" $(bash -c 'echo packages/*/sources.js')
). I guess them not being supported would be a surprise to most users, though.
Additional context
Ideally the syntax and the glob mechanism should be separate - the shell should expose a new glob
option that would accept an async function that would return the match entries for a given argument and cwd, and default this option to whatever implementation we choose (likely the glob
package). This way the shell consumers will be free to choose a different implementation if they want to, and it keeps the shell dependencies on the fs
module low.