Node glob pattern for every .js file except .spec.js

Javascriptnode.jsGruntjsGlobGrunt Usemin

Javascript Problem Overview


I am looking for a better glob pattern for usemin, i want to to find all .js files but exclude the .spec.js files. I have the following solution so far.

The solution i have at the moment requires me to keep adding file extensions to exclude them, else they get picked up, for example .html files.

I tried to make it only look for .js files and exclude the .spec.js from them but it does not seem to work.

Also adding a !components/**/*.spec.js as another script below does not seem to work.

Javascript Solutions


Solution 1 - Javascript

This glob includes all *.js but not *.spec.js:

components/**/!(*.spec).js

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionroughcoderView Question on Stackoverflow
Solution 1 - JavascriptHeikkiView Answer on Stackoverflow