load-grunt-tasks
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
/optionalDependencies
in your package.json and load grunt tasks that match the provided patterns.
Before
grunt;grunt;grunt;grunt;grunt;grunt;grunt;grunt;grunt;grunt;
After
grunt;
Install
$ npm install --save-dev load-grunt-tasks
Usage
// Gruntfile.jsmodule { // Load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns grunt; grunt; grunt;};
Examples
Load all grunt tasks
grunt;
Equivalent to:
grunt pattern: 'grunt-*' '@*/grunt-*';
Load all grunt-contrib tasks
grunt pattern: 'grunt-contrib-*';
Load all grunt-contrib tasks and another non-contrib task
grunt pattern: 'grunt-contrib-*' 'grunt-shell';
Load all grunt-contrib tasks excluding one
You can exclude tasks using the negate !
globbing pattern:
grunt pattern: 'grunt-contrib-*' '!grunt-contrib-coffee';
Set custom path to package.json
grunt config: '../package';
devDependencies
Only load from grunt scope: 'devDependencies';
devDependencies
and dependencies
Only load from grunt scope: 'devDependencies' 'dependencies';
All options in use
grunt pattern: 'grunt-contrib-*' config: '../package.json' scope: 'devDependencies' requireResolution: true;
Options
pattern
Type: string | string[]
Default: ['grunt-*', '@*/grunt-*']
(Glob pattern)
config
Type: string | object
Default: Path to nearest package.json
scope
Type: string | string[]
Default: ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
Values: 'dependencies'
, 'devDependencies'
, 'peerDependencies'
, 'optionalDependencies'
, 'bundledDependencies'
requireResolution
Type: boolean
Default: false
Traverse up the file hierarchy looking for dependencies like require()
, rather than the default grunt-like behavior of loading tasks only in the immediate node_modules
directory.