npm install beverage


The DRYest gulp for the thirsty.
Because even with:
gulp-npm-run,
gulp-npm-test,
gulp-cause,
sourcegate,
and hal-rc -
I'd still do a lot of copy-pasting between gulpfiles.
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, but there would be no use of beverage
if none of the projects listed are enabled, or configured.
Beverage is all about improving your gulp experience with little to no effort.
Here is a diagram of dependencies / modules that beverage makes more convenient to use.


All that's needed in a gulpfile.js, besides gulp, for starters, is:
``javascript`
var gulp = require('beverage')(require('gulp'), {
// 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:
`javascript`
var gulp = require(‘beverage’)(require(‘gulp’))
Or the absolute simplest gulpfile.js:
`javascript`
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.
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 via gulpfile.jscausality: []
- add declarative tasks via gulp-causeharp: {}
- web server and browser-sync via gulp-harptest: {}
- will setup gulp test provided there is a npm test script, see gulp-npm-test for configuration optionsscripts: {}
- makes gulp tasks for all your package.json scripts, see gulp-npm-run for optional configuration, the test script / task is better with gulp-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:
`sh`
gulp helpor gulp
or beve
or beverage
Help is the default gulp task. Create a ’default’ task to change that.
Here is an example output:
`text
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:
`javascript`
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:
1. index.js - look at the def function (it has a few defaults)./node_modules/beverage/node_modules/hal-rc/.beverage
2. - where I keep hal-rc defaults, in the future there could be more defaults between steps 2 and 3..../.beverage
3. - your project options via a configuration filegulpfile.js
4. - 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:
`javascript`
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:
`javascript`
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
}
`sh``
npm test

This is free and unencumbered public domain software.
For more information, see UNLICENSE.