gulp-tasks-manager
Gulp tasks manager. If you have too many tasks, you can split tasks into multiple pieces with this tool.
Install
npm install gulp-tasks-manager --save-dev
Demo
For example, here is the file structure of an app:
/--app |--build |--tasks |--scriptjs |--stylejs |--gulpfilejs |--js |--css |--node_modules |--packagejson
in gulpfile.js
:
var gulp = plugins = tasks = task = ; ;; gulp;
in tasks/script.js
:
module { var cxt = ns path = src: dst: ; gulp; gulp;};
in tasks/style.js
:
module { var cxt = ns path = src: dst: ; gulp; gulp;};
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 knowplugins
:gulp-load-plugins
(preferred) or a self-defined objectopts
: optionsrootDir
: 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
: namespacefilename
: if missed, default toname
- ns
ns.name
: the namespacens.context(dir)
: locate the context dir of a namespace, return a function which is used to locate resources in the module represented by this namespacens(taskName)
: return string ofnamespace:taskName
and add it to the task listns([taskName1, taskName2, ...])
: return an array of string with each item is the format ofnamespace:taskNamex
License
MIT