gloup
v4.0.0
Published
Mini task runner based on bach (DEPRECATED)
Downloads
6
Maintainers
Readme
gloup
Another mini task runner based on bach
Deprecated
This project is no longer maintained.
Features
- One task = one file = one function
- Task on the command line are executed in series
- Compose task in parallel or in series (based on bach)
- Supports node's (or iojs) flags on the command line
This tool as been drafted for some specific needs: use it if you like, enhance it if you don't. Else gulp is a better fit for you.
Installation
npm install --save gloup
Usage
With the folder structure below:
├─ myapp
└─ tasks
├─ bundle.js
├─ clean.js
├─ dev.js
├─ dist.js
├─ statics.js
└─ serve.js
myapp:
The executable main script (chmod +x myapp
)
#!/usr/bin/env node
var gloup = require('gloup')
gloup(__dirname + '/tasks')
tasks/clean.js: A task must export a function that return anything async-done supports (stream, promise, etc.)
var del = require('promised-del')
var resolve = require('path').resolve
module.exports = function () {
return del(['build'], {
cwd: resolve(__dirname, '../../')
})
}
tasks/dist.js: You can compose tasks using tasks name (based on filename) or function
var series = require('gloup').series(__dirname)
var parallel = require('gloup').parallel(__dirname)
module.exports = series([
'clean',
parallel('bundle','statics'),
function () {
return new Promise(function (resolve, reject) {
// ...
})
}
])
Now, myapp
can be used as a task runner
> myapp clean bundle serve
gloup ⇢ clean +0ms
gloup ⇠ clean +0ms
gloup ⇢ bundle +1s
gloup ⇠ bundle +6s
gloup ⇢ serve +0ms
gloup ⇠ serve +2ms
Start a composed task
> myapp dist
gloup ⇢ clean +0ms
gloup ⇠ clean +0ms
gloup ⇢ bundle +1s
gloup ⇢ statics +1s
gloup ⇠ bundle +6s
gloup ⇠ statics +6s
gloup ⇢ serve +0ms
gloup ⇠ serve +2ms
With node options:
> myapp --debug --es_staging serve
Debugger listening on port 5858
gloup ⇢ serve +0ms
gloup ⇠ serve +2ms
Quiet mode (remove gloup messages):
> myapp serve --quiet
api
Create a command line tool
#!/usr/bin/env node
var gloup = require('gloup')
// Path to the tasks folder
gloup(__dirname + '/tasks')
// Force node (iojs) flags
gloup(__dirname + '/tasks', {
flags: ['--es_staging']
})
Use series
and parallel
composer (just a convenient wrapper around bach) to compose tasks with name.
// gloup.series(taskFolder) -> {function} :
var series = require('gloup').series(__dirname)
// gloup.parallel(taskFolder) -> {function} :
var parallel = require('gloup').parallel(__dirname)
module.exports = series(['clean', parallel('bundle','statics')])