node-glob match all files but a single file

639 Views Asked by At

I'm trying to write a glob pattern that matches all files *.* but not index.html.

I started with: *.*!(index.html), but this doesn't result in the correct output.

I'm reading node-glob documentation.

After looking at this answer

I feel it may not be achievable...?

I don't want to use the exclude option in the glob options, I want to try and do it using the glob pattern alone.

1

There are 1 best solutions below

0
On

This is old I know, but I wanted something similar. The answer is you're misinterpreting the docs: to match all files but not index.html is just !(index.html). You don't need the *.*. So, for example, to match all files in your dist folder and subfolders, but not index.html, would be ./dist/**/!(index.html).