Skip to content

Support glob patterns in the shell #22

Open

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededshellThis issue is about @yarnpkg/shell

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions