Search code examples
gulpgulp-inject

Gulp file ordering not as expected


I have the glob:

'app/scripts/page-*/js/*.js'

How can I get gulp to sort the following 2 files in this order:

page-user.js
page-user-create.js

I need page-xxx.js to always go first. I tried gulp-natural-sort using both ascending and descending order but I still get the same result:

page-user-create.js
page-user.js

Solution

  • You can try gulp-order instead:

    .pipe(order([
      'page-*([^-]).js',
      'page-*-*.js'
    ]))
    

    This should sort all files with a single - in their file name before those files with two - in their file name.