globkarma-runnerminimatch

karma config - exclude src subfolder


i have a problem with the glob syntax in the karma files config. Let's assume this folder structure:

-js
   -one
      -subone
   -two
   -special
   -four

Now, I want all files/folders within js to be served and included EXCEPT the special folder should only be served but NOT included.

I tried this config:

files: [
    {pattern: 'js/**/!(special)/*.js', watched: false, served: true, included: true},
    {pattern: 'js/special/**/*.js', watched: false, served: true, included: false}
],

I also tried this config, because I found something seemingly similar on the web:

files: [
    {pattern: 'js/*[!special]/*.js', watched: false, served: true, included: true},
    {pattern: 'js/special/**/*.js', watched: false, served: true, included: false}
],

but they don't work. The result currently always is: The special folder with its contents is served, but no other js file/folder.

Update

I now directly played with node.js minimatch lib and tried these pattern:

files: [
    {pattern: 'js/!(special)/**/*.js', watched: false, served: true, included: true},
    {pattern: 'js/special/**/*.js', watched: false, served: true, included: false}
],

This works in minimatch, but not in Karma. Why not?

--end update--

Can someone help me coming up with the correct rule? Thanks.


Solution

  • Found the problem. In order to really reach all files I needed to have an additional rule:

    {pattern: 'js/*.js', watched: false, served: true, included: true},
    

    Quite obvious, if I look at it now, just didn't see it in the first place.