grunt-file-order

1.0.0 • Public • Published

grunt-file-order

A grunt extension for ordering files after selection.
Adds order attribute to both config files and grunt.file.expand.

Installation

$ npm install --save grunt-file-order

Usage

In config files

require('grunt-file-order'); // global addition to grunt
module.exports = function (grunt, options) {
  return {
    copyFiles: {
      files: [
        {
          expand: true,
          src: ['<%= sourcedir %>**'],
          dest: '<%= outputdir %>',
          order: function(filepaths) {
            // sort alphabetically
            return filepaths.sort(function(a,b) {
              return a>? 1 : a<? -1 : 0;
            });
          }
        }
      ]
    }
  };
};

In task grunt.file.expand

require('grunt-file-order'); // global addition to grunt
 
var sourcedir = "./src";
var files = grunt.file.expand({ 
  order: function(filepaths) {
    // sort alphabetically
    return filepaths.sort(function(a,b) {
      return a>? 1 : a<? -1 : 0;
    });
  }
}, sourcedir);

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-file-order

Weekly Downloads

247

Version

1.0.0

License

none

Last publish

Collaborators

  • oliver.foster