Skip to main content
2 of 7
added 518 characters in body
Fravadona
  • 1.6k
  • 5
  • 14

In an extglob, !(.min) can match everything but .min (and anything that contains a /); that includes the empty string!

When you test foo/bar/baz/test.min.js with the glob foo/bar/**/*!(.min).js you get a hit because:

  • foo/bar/ matches foo/bar/
  • **/ matches bar/
  • * matches test.min
  • !(.min) matches the empty string
  • .js matches .js

The meaning that you want from !(.min) is in fact "anything that doesn't end with .min", which is the negation of *.min, so use !(*.min) to fix the issue:

foo/bar/**/!(*.min).js
Fravadona
  • 1.6k
  • 5
  • 14