Search code examples
javascriptnode.jsgruntjsglob

grunt globbing except a file


I have a list of files:

 'app/scripts/module.js',
 'app/templates/templates.js',
 'app/scripts/**/*.js'

This will load app/scripts/module.js, app/templates/templates.js and then all the files under app/scripts/**/*.js except the one that was loaded before (module.js).
Now I want it to load another file located in app/scripts/a.js at the end of the list.
The problem is that when app/scripts/**/*.js is loaded, it already load app/scripts/a.js.
I want to write something like app/scripts/**/*.js (!a.js) - load all except a.js.
It this possible?


Solution

  • You want to load 'a.js', but after the other scripts? How about this, (pulled from the docs)

    ['app/scripts/**/*.js', '!app/scripts/**/a.js', 'app/scripts/**/a.js' ]
    

    If you don't wish to load 'a.js', then just remove the last entry in the array.

    ['app/scripts/**/*.js', '!app/scripts/**/a.js']
    

    http://gruntjs.com/configuring-tasks#globbing-patterns