load-grunt-subtasks

Load multiple grunt tasks from subprojects using globbing patterns

load-grunt-subtasks

Load multiple grunt tasks from subprojects using globbing patterns

Based on the wonderful load-grunt-tasks by Sindre Sorhus, but rather than loading all of the grunt tasks from the current module, it allows you to load other grunt tasks from inside of node_modules.

Install with npm: npm install --save-dev load-grunt-subtasks

By default, it will load all of the grunt-* tasks within node_modules/*/node_modules

// Gruntfile.js 
 
module.exports = function (grunt) {
  // load all grunt-* tasks from within the `shared` module 
  require('load-grunt-subtasks')(grunt);
 
  grunt.initConfig({});
  grunt.registerTask('default', []);
}
require('load-grunt-subtasks')(grunt);

Equivalent to:

require('load-grunt-subtasks')(grunt, {
  pattern: 'grunt-*'
});
require('load-grunt-subtasks')(grunt, {
  pattern: 'grunt-contrib-*'
});
require('load-grunt-subtasks')(grunt, {
  pattern: ['grunt-contrib-*', 'grunt-shell']
});

You can exclude tasks using the negate ! globbing pattern:

require('load-grunt-subtasks')(grunt, {
  pattern: ['grunt-contrib-*', '!grunt-contrib-coffee']
});
require('load-grunt-subtasks')(grunt, {
  base: './node_modules/shared/'
});
require('load-grunt-subtasks')(grunt, {
  base: ['./node_modules/shared/', './node_modules/devDep']
});
require('load-grunt-subtasks')(grunt, {
  pattern: ['grunt-contrib-*', 'lumbar'],
  base: './node_modules/shared/'
});

Type: String|Array Default: 'grunt-*'

By default grunt-* will be used as the globbing pattern.

Type: String|Array Default: './node_modules/*/node_modules'

Note that base will be searched for literally, and not globbed

MIT © Patrick Kettner