0

How can I exclude arbitrary file(s) with arbitrary filename extension from glob selection?

For example: we need all .pug and .haml files in C:\Users\User1\projectname\src\markup except index.pug (but index.haml is O'K).

The glob

'C:\\Users\\User1\\projectname\\src\\markup\\!(index).+(pug|haml)'

excludes both index.pug and index.haml - this is not that we want, and also there is no enougnh flexibility.

Let's make clear:

  1. In this question we don't need to receive files by glob - the target is just create single glob selection. So the solutions like globby(['C:\\Users\\User1\\projectname\\src\\markup\\*.+(pug|haml)', '!C:\\Users\\User1\\projectname\\src\\markup\\index.pug']); are not matches to this question.
  2. If it's impossible - to exclude arbitrary file(s) with arbitrary extension(s) from glob - please say such as.

I tried

minimatch(
    'C:\\Users\\bokovgleb\\projectname\\src\\src\\index.pug',
    'C:\\Users\\bokovgleb\\projectname\\src\\src\\*(*.pug|!(index.pug))'
)

based on comment to this answer. It returns true...

Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124

1 Answers1

1

For example: we need all .pug and .haml files in C:\Users\User1\projectname\src\markup except index.pug (but index.haml is O'K).

I came up with

/markup/!(*index){.pug,.haml,index.haml}

You can test it using globster.xyz

Domajno
  • 587
  • 1
  • 5
  • 13