Skip to content

gulpsome/beverage

Repository files navigation

beverage -- give it a gulp

version npm dependencies js-standard-style

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.

Why

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.

What

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.

Ecosystem The Ready Column

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...

Use

NPM

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

Configure

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.js
  • causality: [] add declarative tasks via gulp-cause
  • harp: {} web server and browser-sync via gulp-harp
  • test: {} will setup gulp test provided there is a npm test script, see gulp-npm-test for configuration options
  • scripts: {} 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 favored
  • sourcegate & sourceopt, the latter is optional, both handled by hal-rc, where they are documented

CLI

There is also a beverage-cli, that can be installed separately.

Help

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.

Defaults & Overrides

Beverage options are deep-merged in the following order of sources:

  1. index.js - look at the def function (it has a few defaults)
  2. ./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...
  3. ./.beverage - your project options via a configuration file
  4. gulpfile.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
}

Test Build Status

npm test

Depvelop Dependency Status devDependency Status

js-standard-style

Unlicensed

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

Releases

No releases published

Packages

No packages published