# load-grunt-tasks

> Load multiple grunt tasks using globbing patterns

Latest version **5.1.0** (published 2019-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-grunt-tasks
pnpm add load-grunt-tasks
yarn add load-grunt-tasks
bun add load-grunt-tasks
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2019-07-31 |
| First published | 2013-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 4 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 924 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | dependencies, glob, grunt, load, match, matchdep, pattern, require, tasks |

## Links

- npm: https://www.npmjs.com/package/load-grunt-tasks
- Repository: https://github.com/sindresorhus/load-grunt-tasks
- Homepage: https://github.com/sindresorhus/load-grunt-tasks#readme
- Issues: https://github.com/sindresorhus/load-grunt-tasks/issues
- npm.io page: https://npm.io/package/load-grunt-tasks

## Dependencies (4)

- [arrify](https://npm.io/package/arrify.md) ^2.0.1
- [pkg-up](https://npm.io/package/pkg-up.md) ^3.1.0
- [multimatch](https://npm.io/package/multimatch.md) ^4.0.0
- [resolve-pkg](https://npm.io/package/resolve-pkg.md) ^2.0.0

## Recent versions

- 5.1.0 (latest) — 2019-07-31
- 5.0.0 — 2019-05-23
- 4.0.0 — 2018-05-07
- 3.5.2 — 2016-08-12
- 3.5.1 — 2016-08-12
- 3.5.0 — 2016-04-08
- 3.4.1 — 2016-03-01
- 3.4.0 — 2015-12-19
- 3.3.0 — 2015-09-21
- 3.2.0 — 2015-05-21
- 3.1.0 — 2015-01-29
- 3.0.0 — 2015-01-22
- 2.0.0 — 2014-12-22
- 1.0.0 — 2014-10-22
- 0.6.0 — 2014-06-21
- … 9 more at https://npm.io/package/load-grunt-tasks/versions

## README

# load-grunt-tasks [![Build Status](https://travis-ci.org/sindresorhus/load-grunt-tasks.svg?branch=master)](https://travis-ci.org/sindresorhus/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

```js
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

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


## Install

```
$ npm install --save-dev load-grunt-tasks
```


## Usage

```js
// Gruntfile.js
module.exports = grunt => {
	// Load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
	require('load-grunt-tasks')(grunt);

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


## Examples

### Load all grunt tasks

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

Equivalent to:

```js
require('load-grunt-tasks')(grunt, {pattern: ['grunt-*', '@*/grunt-*']});
```

### Load all grunt-contrib tasks

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

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

```js
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:

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

### Set custom path to package.json

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

### Only load from `devDependencies`

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

### Only load from `devDependencies` and `dependencies`

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

### All options in use

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


## Options

### pattern

Type: `string | string[]`<br>
Default: `['grunt-*', '@*/grunt-*']` ([Glob pattern](https://github.com/isaacs/minimatch))

### config

Type: `string | object`<br>
Default: Path to nearest package.json

### scope

Type: `string | string[]`<br>
Default: `['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']`<br>
Values: `'dependencies'`, `'devDependencies'`, `'peerDependencies'`, `'optionalDependencies'`, `'bundledDependencies'`

### requireResolution

Type: `boolean`<br>
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.

---
_Source: https://npm.io/package/load-grunt-tasks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
