<commit_before>gulp-import-tasks
=================

Imports Gulp tasks from a local directory, rather than from your gulpfile.

Based on [gulp-load-tasks][external_gulp-load-tasks], but better (and actively maintained)!



***



Install
-------

```
$ npm install gulp-import-tasks
```

<small>**Note:** [`gulp`][external_gulp] is a required peer dependency.</small>


Usage
-----------

#### Quick Start

Simply require the package within your `gulpfile.js`. By default, this will load all Gulp tasks that exist within a local `tasks` directory.

```js
// gulpfile.js

require('gulp-import-tasks')();
```

```js
// tasks/default.js

module.exports = [
  'clean'
];
```

```js
// tasks/clean.js

const clean = require('gulp-clean');

module.exports = function (gulp) {
  return gulp.clean('dist', { read: false })
    .pipe(clean());
};
```

As you can see above, `gulp-import-tasks` will automatically send `gulp` as the first function parameter. You can add additional parameters using [advanced options][section_advanced].


#### Custom Directory

You can customize the tasks directory by passing in the name of your custom directory as the first parameter. The following will check for tasks within the `gulp/tasks` directory.

```js
// gulpfile.js

require('gulp-import-tasks')('gulp/tasks');
```

Or, you can define it by passing in an options object instead. See [advanced usage][section_advanced].

```js
// gulpfile.js

require('gulp-import-tasks')({
  dir: 'gulp/tasks'
});
```


#### Asynchronous Tasks

Gulp will automatically send an asynchronous callback function as the last parameter in your task definition. Use this to make your task asynchronous! Read more about asynchronous tasks in the Gulp docs [here][external_gulp-async].

```js
// tasks/async.js

module.exports = function (gulp, done) {
  doSomethingAsync(() => {
    done();
  });
};
```


Advanced
--------

Using the options parameter, you may specify permissible file extensions, as well as any additional function parameters.

#### Options

| Option       | Type             | Description                                                          | Default   |
|:-------------|:-----------------|:---------------------------------------------------------------------|:----------|
| `dir`        | `string`         | The directory that contains your Gulp tasks.                         | `tasks`   |
| `extensions` | `Array.<string>` | Only load files from the tasks directory that have these extensions. | `['.js']` |
| `params`     | `Array.<any>`    | Additional parameters to pass into imported task.                    | `[]`      |


#### Example

```js
// gulpfile.js

const config = {
  build: 'dist'
};

require('gulp-import-tasks')({
  dir: 'gulp/tasks',
  extensions: ['.js'],
  params: [
    config
  ]
});
```

```js
// gulp/tasks/default.js

module.exports = [
  'clean'
];
```

```js
// gulp/tasks/clean.js

const clean = require('gulp-clean');

module.exports = function (gulp, config) {
  return gulp.clean(config.build, { read: false })
    .pipe(clean());
};
```

```js
// gulp/tasks/async.js

module.exports = function (gulp, config, done) {
  doSomethingAsync(() => {
    done();
  });
};
```



Authors
-------
* [<NAME>]


License
-------
MIT




[Nathan Buchar]: mailto:<EMAIL>

[section_install]: #install
[section_usage]: #usage
[section_advanced]: #advanced

[external_gulp-load-tasks]: https://npmjs.com/package/gulp-load-tasks
[external_gulp-async]: https://github.com/gulpjs/gulp/blob/master/docs/API.md#async-task-support
[external_gulp]: https://npmjs.com/package/gulp<commit_msg>Remove asnyc mention from README<commit_after>gulp-import-tasks
=================

Imports Gulp tasks from a local directory, rather than from your gulpfile.

Based on [gulp-load-tasks][external_gulp-load-tasks], but better (and actively maintained)!



***



Install
-------

```
$ npm install gulp-import-tasks
```

<small>**Note:** [`gulp`][external_gulp] is a required peer dependency.</small>


Usage
-----------

#### Quick Start

Simply require the package within your `gulpfile.js`. By default, this will load all Gulp tasks that exist within a local `tasks` directory.

```js
// gulpfile.js

require('gulp-import-tasks')();
```

```js
// tasks/default.js

module.exports = [
  'clean'
];
```

```js
// tasks/clean.js

const clean = require('gulp-clean');

module.exports = function (gulp) {
  return gulp.clean('dist', { read: false })
    .pipe(clean());
};
```

As you can see above, `gulp-import-tasks` will automatically send `gulp` as the first function parameter. You can add additional parameters using [advanced options][section_advanced].


#### Custom Directory

You can customize the tasks directory by passing in the name of your custom directory as the first parameter. The following will check for tasks within the `gulp/tasks` directory.

```js
// gulpfile.js

require('gulp-import-tasks')('gulp/tasks');
```

Or, you can define it by passing in an options object instead. See [advanced usage][section_advanced].

```js
// gulpfile.js

require('gulp-import-tasks')({
  dir: 'gulp/tasks'
});
```


#### Asynchronous Tasks

Currently no support. Accepting pull requests.


Advanced
--------

Using the options parameter, you may specify permissible file extensions, as well as any additional function parameters.

#### Options

| Option       | Type             | Description                                                          | Default   |
|:-------------|:-----------------|:---------------------------------------------------------------------|:----------|
| `dir`        | `string`         | The directory that contains your Gulp tasks.                         | `tasks`   |
| `extensions` | `Array.<string>` | Only load files from the tasks directory that have these extensions. | `['.js']` |
| `params`     | `Array.<any>`    | Additional parameters to pass into imported task.                    | `[]`      |


#### Example

```js
// gulpfile.js

const config = {
  build: 'dist'
};

require('gulp-import-tasks')({
  dir: 'gulp/tasks',
  extensions: ['.js'],
  params: [
    config
  ]
});
```

```js
// gulp/tasks/default.js

module.exports = [
  'clean'
];
```

```js
// gulp/tasks/clean.js

const clean = require('gulp-clean');

module.exports = function (gulp, config) {
  return gulp.clean(config.build, { read: false })
    .pipe(clean());
};
```



Authors
-------
* [<NAME>]


License
-------
MIT




[<NAME>]: mailto:<EMAIL>

[section_install]: #install
[section_usage]: #usage
[section_advanced]: #advanced

[external_gulp-load-tasks]: https://npmjs.com/package/gulp-load-tasks
[external_gulp-async]: https://github.com/gulpjs/gulp/blob/master/docs/API.md#async-task-support
[external_gulp]: https://npmjs.com/package/gulp
{'fraction_non_alphanumeric': 0.19284235433303756, 'fraction_numerical': 0.0, 'mean_word_length': 2.7739955357142856, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4166421', 'n_tokens_mistral': 2110, 'n_tokens_neox': 1986, 'n_words': 584}