-
Notifications
You must be signed in to change notification settings - Fork 0
/
beverage.js
70 lines (57 loc) · 1.85 KB
/
beverage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import 'source-map-support/register'
import {prefquire, pkg, isLocal, isGulp, gulpHelpify} from 'be-goods'
import sourcegate from 'sourcegate'
import pick from 'lodash.pick'
let req = prefquire({dev: true, exitOnError: true})
function def (opts = {}) {
opts.dotBeverage = opts.dotBeverage || [
'node_modules/beverage/node_modules/hal-rc',
'.'
]
let o = sourcegate([{
scripts: {
requireStrict: true
}
}].concat(opts.dotBeverage.map(file => file + '/.beverage'), opts))
if (o.hasOwnProperty('test') && isLocal('gulp-npm-test')) {
// gulp-npm-test does testing better than gulp-npm-run
// NOTE: don't be put-off by `spec.coffee` and change it to match your tests
return sourcegate([{
scripts: {exclude: ['test']},
test: {
testsRe: '\\.spec\\.coffee$'
}
}, o])
} else {
return o
}
}
module.exports = function (first, second) {
let gulp, o
if (isGulp(first)) {
gulp = gulpHelpify(first)
o = def(second)
} else {
// NOTE: gulp must be locally installed (relative to gulpfile.js / cwd).
// Gulp insists on it. Both gulp-cli and beverage-cli enforce it.
gulp = gulpHelpify(req('gulp', {forceLocal: true}))
o = def(first)
}
gulp.task('beverage', 'The recipe of this beverage.', () => {
console.log('\nCurrent beverage options:')
console.log('\n' + JSON.stringify(o, null, 2) + '\n')
})
if (pkg.scripts) {
if (o.scripts) req('gulp-npm-run')(gulp, o.scripts)
if (o.test && pkg.scripts.test) {
req('gulp-npm-test', {forceLocal: true})(gulp, o.test)
}
}
if (o.sourcegate && o.sourcegate.length) {
o.sourceopt = o.sourceopt || {}
req('hal-rc')(pick(o, ['sourcegate', 'sourceopt']), gulp)
}
if (o.harp) req('gulp-harp', {forceLocal: true})(gulp, pick(o, ['harp']))
if (o.causality) req('gulp-cause')(gulp, o.causality)
return gulp
}