Giter Club home page Giter Club logo

load-grunt-tasks's Introduction

load-grunt-tasks Build Status Built with Grunt

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 matches the provided patterns.

Note the new argument signature as of 0.2.0.

Before

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');

After

require('load-grunt-tasks')(grunt);

Install

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

Example config

// Gruntfile.js
module.exports = function (grunt) {
	// load all grunt tasks matching the `grunt-*` pattern
	require('load-grunt-tasks')(grunt);

	grunt.initConfig({});
	grunt.registerTask('default', []);
}

Usage examples

Load all grunt tasks

require('load-grunt-tasks')(grunt);

Equivalent to:

require('load-grunt-tasks')(grunt, {pattern: 'grunt-*'});

Load all grunt-contrib tasks

require('load-grunt-tasks')(grunt, {pattern: 'grunt-contrib-*'});

Load all grunt-contrib tasks and another non-contrib task

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

Load all grunt-contrib tasks excluding one

You can exclude tasks using the negate ! globbing pattern:

require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', '!grunt-contrib-coffee']});

Set custom path to package.json

require('load-grunt-tasks')(grunt, {config: '../package'});

Only load from devDependencies

require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});

Only load from devDependencies and dependencies

require('load-grunt-tasks')(grunt, {scope: ['devDependencies', 'dependencies']});

All options in use

require('load-grunt-tasks')(grunt, {
	pattern: 'grunt-contrib-*',
	config: '../package.json',
	scope: 'devDependencies'
});

Options

pattern

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

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

config

Type: String|Object
Default: Path to nearest package.json

scope

Type: String|Array
Default: ['dependencies', 'devDependencies', 'peerDependencies']

License

MIT © Sindre Sorhus

load-grunt-tasks's People

Contributors

sboudrias avatar sindresorhus avatar sulmanen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.