grunt-file-order
v1.0.0
Published
Helpers for ordering files
Downloads
525
Readme
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>b ? 1 : a<b ? -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>b ? 1 : a<b ? -1 : 0;
});
}
}, sourcedir);