Load multiple grunt tasks using globbing patterns
Usually you would have to load each task one by one, which is unnecessarily cumbersome.
This module will read the dependencies
/devDependencies
/peerDependencies
in your package.json and load grunt tasks that match the provided patterns.
Note the new argument signature as of 0.2.0.
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-sizediff');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-styl');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-bower-requirejs');
require('load-grunt-tasks')(grunt);
Install with npm: npm install --save-dev load-grunt-tasks
// Gruntfile.js
module.exports = function (grunt) {
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
grunt.initConfig({});
grunt.registerTask('default', []);
}
require('load-grunt-tasks')(grunt);
Equivalent to:
require('load-grunt-tasks')(grunt, {pattern: 'grunt-*'});
require('load-grunt-tasks')(grunt, {pattern: 'grunt-contrib-*'});
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-shell']});
You can exclude tasks using the negate !
globbing pattern:
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', '!grunt-contrib-coffee']});
require('load-grunt-tasks')(grunt, {config: '../package'});
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
require('load-grunt-tasks')(grunt, {scope: ['devDependencies', 'dependencies']});
require('load-grunt-tasks')(grunt, {
pattern: 'grunt-contrib-*',
config: '../package.json',
scope: 'devDependencies'
});
Type: String|Array
Default: 'grunt-*'
(globbing pattern)
Type: String|Object
Default: Path to nearest package.json
Type: String|Array
Default: ['dependencies', 'devDependencies', 'peerDependencies']
MIT © Sindre Sorhus