The DRYest gulp for the thirsty.
This beverage
simplifies your npm run
experience with little to no effort, it just becomes gulp
too.
This beverage
doubles your tasty gulp
fun with even less effort, it's all the same, gulp
on.
Beverage is something to pour in a gulp
cup.
Because even with: gulp-npm-run, gulp-npm-test, gulp-cause, hal-rc, and gulp-harp - I'd still do a lot of copy-pasting between gulpfiles. Just turning your npm scripts into gulp tasks, with a single line of code, should be enough motivation.
There is almost always test
+ test:watch
,
and often some kind of build
+ build:watch
tasks,
and some linter / hinter config, that could be common /
similar across projects, as well as a dev
task that
runs the above and perhaps some other tasks in parallel...
All of the above are optional, yet there would be no use of beverage if none of these projects are enabled by configuration, these or possibly some others not listed up-front. Make your own beverage. Read on to find out what could be in it.
Here is a diagram of dependencies / modules beverage
can help with:
Follow the infographic link above for explanation about what the colors mean. The modules are useful on their own, mostly with gulp, though also developed with beverage. It can be easy to forget what the interdependencies are. I come back to it when I need a reminder. If you like npm link
and would like to hack on these, I recommend npm-interlink to bootstrap a development environment. That can be useful for any project with a number of interdependent modules...
All that's needed in a gulpfile.js
, besides gulp, for starters, is:
var gulp = require('beverage')(require('gulp'), {
// beverage options listed next
})
// use gulp as you would otherise
Or, even simpler, if beverage fulfills all your gulp task needs, you could load options from a .beverage
file with just the following line in gulpfile.js
to set gulp up:
var gulp = require(‘beverage’)(require(‘gulp’))
Or the absolute simplest gulpfile.js
:
var gulp = require(‘beverage’)()
Beverage will use your local gulp and you must have it installed, something that gulp itself insists on. Otherwise you will be reminded. The options in this last example come from .beverage
but you could also provide you own as a first argument:
var gulp = require(‘beverage’)({
// beverage options next...
})
// anything else you #gulp
It will not do anything unless given some options:
dotBeverage: []
contains the relative paths where beverage will look for.beverage
configuration files - the default is[‘node_modules/beverage/node_modules/hal-rc’, ’.’]
- this is the only option one would have to override viagulpfile.js
causality: []
add declarative tasks via gulp-causeharp: {}
web server and browser-sync via gulp-harptest: {}
will setupgulp test
provided there is anpm test
script, see gulp-npm-test for configuration optionsscripts: {}
makes gulp tasks for all yourpackage.json
scripts, see gulp-npm-run for optional configuration, the test script / task is better withgulp-npm-test
which is automatically favoredsourcegate
&sourceopt
, the latter is optional, both handled by hal-rc, where they are documented
There is also a beverage-cli, that can be installed separately.
To see what tasks beverage has created:
gulp help
# or gulp
# or beve
# or beverage
Help is the default gulp
task. Create a ’default’
task to change that.
Here is an example output:
Usage
gulp [task]
Available tasks
beverage The recipe of this beverage.
build sourcegates.js
build:watch sourcegates.coffee
dev DEVELOP
help Display this help text.
sourcegate Write sourcegate targets.
sourcegate:watch Watch sourcegate sources for changes.
test A gulp-npm-test task, using `mocha`.
test:watch sourcegates.js,test/*.coffee
For which, I only had to add a dev
task:
gulp.task('dev', 'DEVELOP', ['build', 'build:watch', 'test:watch'])
Credits to gulp-help.
See the current beverage configuration options with beverage -o
or gulp beverage
.
Hope this helps.
Beverage options are deep-merged in the following order of sources:
index.js
- look at thedef
function (it has a few defaults)./node_modules/beverage/node_modules/hal-rc/.beverage
- where I keep hal-rc defaults, in the future there could be more defaults between steps 2 and 3..../.beverage
- your project options via a configuration filegulpfile.js
- your project options via javascript code
Steps 2 and 3 can be changed with a dotBeverage
option given through gulpfile.js
. It’s an array of paths where .beverage
is to be looked for. For example, if you had a package called special-recipe
that had all your default configuration, here is a gulpfile.js
starting point:
var gulp = require(‘beverage’)(require(‘gulp’), {
dotBeverage: [‘node_modules/special-recipe’, ’.’]
})
One could of-course write a module that wraps beverage, whether to change default options or add functionality that my beverage won’t include:
var merge = require('lodash.merge')
module.exports = function (gulpIn, options) {
var gulp = require('beverage')(gulpIn, merge({
// your special beverage options
},
options
))
// do more with gulp…
return gulp
}
npm test
This is free and unencumbered public domain software. For more information, see UNLICENSE.