# gulp-tasks-manager

> Gulp tasks manager

Latest version **1.0.2** (published 2015-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-tasks-manager
pnpm add gulp-tasks-manager
yarn add gulp-tasks-manager
bun add gulp-tasks-manager
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-08-23 |
| First published | 2015-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex Sun |
| Maintainers | syaning |
| Keywords | gulp, gulp-task, gulp-tasks, gulp-task-manager, gulp-tasks-manager |

## Links

- npm: https://www.npmjs.com/package/gulp-tasks-manager
- Repository: https://github.com/syaning/gulp-tasks-manager
- Homepage: https://github.com/syaning/gulp-tasks-manager#readme
- Issues: https://github.com/syaning/gulp-tasks-manager/issues
- npm.io page: https://npm.io/package/gulp-tasks-manager

## Recent versions

- 1.0.2 (latest) — 2015-08-23
- 1.0.1 — 2015-08-23

## README

# gulp-tasks-manager

Gulp tasks manager. If you have too many tasks, you can split tasks into multiple pieces with this tool.

### Install

```sh
npm install gulp-tasks-manager --save-dev
```

### Demo

For example, here is the file structure of an app:

```javascript
/--app
  |--build
      |--tasks
          |--script.js
          |--style.js
      |--gulpfile.js
  |--js
  |--css
  |--node_modules
  |--package.json
```

in `gulpfile.js`:

```javascript
var gulp = require('gulp'),
	plugins = require('gulp-load-plugins')(),
	tasks = require('gulp-tasks-manager'),
	task = tasks(gulp, plugins, {
		rootDir: '../',
		taskDir: './tasks'
	});

task('script');
task('style');

gulp.task('default', tasks.list());
```

in `tasks/script.js`:

```javascript
module.exports = function(gulp, plugins, ns) {
	var cxt = ns.context('./js'),
		path = {
			src: cxt('./**/*.js'),
			dst: cxt('./build')
		};

	gulp.task(ns('build'), function() {
		gulp.src(path.src)
			.pipe(plugins.uglify())
			.pipe(gulp.dest(path.dst));
	});

	gulp.task(ns('watch'), function() {
		gulp.watch(path.js, ns(['build']));
	});
};
```

in `tasks/style.js`:

```javascript
module.exports = function(gulp, plugins, ns) {
	var cxt = ns.context('./css'),
		path = {
			src: cxt('./**/*.less'),
			dst: cxt('./build')
		};

	gulp.task(ns('build'), function() {
		gulp.src(path.src)
			.pipe(plugins.less())
			.pipe(gulp.dest(path.dst));
	});

	gulp.task(ns('watch'), function() {
		gulp.watch(path.less, ns(['build']));
	});
};
```

then just run `gulp`.

If you want:

- just build and watch script, run `gulp script`
- just build but not watch style, run `gulp style:build`

when executing `task(script)`, it is just:

- `gulp.task('script:build', function(){})`
- `gulp.task('script:watch', function(){})`
- `gulp.task('script', ['script:build', 'script:watch'])`

### API

- **tasks(gulp, plugins [, opts])**
	- `gulp`: the gulp as we all know
	- `plugins`: [`gulp-load-plugins`](https://github.com/jackfranklin/gulp-load-plugins)(preferred) or a self-defined object
	- `opts`: options
		- `rootDir`: default to `./`
		- `taskDir`: default to `./`
- **tasks.list()**
	- list main tasks
	- return value is the format of `[namespace1, namespace2, ...]`
- **tasks.listAll()**
	- list all tasks(main tasks and subtasks)
	- return value is the format of `{namespace1: [subtask1, subtask2], namespace2: [...], ...}`
- **task(name [, filename])**
	- `name`: namespace
	- `filename`: if missed, default to `name`
- **ns**
	- `ns.name`: the namespace
	- `ns.context(dir)`: locate the context dir of a namespace, return a function which is used to locate resources in the module represented by this namespace
	- `ns(taskName)`: return string of `namespace:taskName` and add it to the task list
	- `ns([taskName1, taskName2, ...])`: return an array of string with each item is the format of `namespace:taskNamex`

### License

MIT

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