node package manager



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


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


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


in gulpfile.js:

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

in tasks/script.js:

module.exports = function(gulp, plugins, ns) {
    var cxt = ns.context('./js'),
        path = {
            src: cxt('./**/*.js'),
            dst: cxt('./build')
    gulp.task(ns('build'), function() {
    gulp.task(ns('watch'), function() {, ns(['build']));

in tasks/style.js:

module.exports = function(gulp, plugins, ns) {
    var cxt = ns.context('./css'),
        path = {
            src: cxt('./**/*.less'),
            dst: cxt('./build')
    gulp.task(ns('build'), function() {
    gulp.task(ns('watch'), function() {, 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'])


  • tasks(gulp, plugins [, opts])
    • gulp: the gulp as we all know
    • plugins: 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
    • 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