I have a simple AngularJs application setup, that looks a bit like this:
client vendor angular bootstrap jquery ... app.module.js app.controller.js ... node_modules angular-mocks ...
I'm setting up a karma.conf.js
file and I want to include angular\angular.js
from vendor
. I don't want to include anything else from vendor
.
Here is what I have in the relevant karma.conf.js
sections:
files: [ 'client/vendor/angular/angular.js', 'client/**/*.js', 'client/**/*.spec.js' ], exclude: [ 'client/vendor/**/*.js' ],
The problem I have is simple: I'm including angular.js
explicitly in files
, but it is then being excluded in the exclude
section pattern.
How can I exclude all of client/vendor
except for angular/angular.js
(and perhaps others later)? The client
directory contains a lot of files, sub-folders, etc, that include my own .js files, so it's not easy to just move everything I want to include into a folder of its own, for example.
Try this:
client/vendor/**/!(angular).js
Example
More filenames can be excluded like this:
client/vendor/**/!(angular|angular-route).js
The patterns used here are called globs.
Here is a short guide to glob functionality in node from node-globs
on GH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With