-
Notifications
You must be signed in to change notification settings - Fork 47
/
gulpfile.js
59 lines (48 loc) · 1.45 KB
/
gulpfile.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
'use strict'
const gulp = require('gulp')
const gutil = require('gulp-util')
const mocha = require('gulp-mocha')
const hf = require('gulp-headerfooter')
const rename = require('gulp-rename')
const uglify = require('gulp-uglify')
const beautify = require('gulp-beautify')
const eslint = require('gulp-eslint')
const DEST = 'dist/'
const paths = ['gulpfile.js', 'src/dot-object.js', 'test/**/*.js']
gulp.task('lint', function (done) {
gulp.src(paths)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
done()
})
gulp.task('mocha', function (done) {
gulp.src(['test/**/*.js'])
.pipe(mocha())
.on('error', gutil.log)
done()
})
gulp.task('watch', function () {
gulp.watch(paths, gulp.series('build-node', 'mocha'))
})
gulp.task('build-node', function (done) {
gulp.src('src/dot-object.js')
.pipe(hf.footer('\nmodule.exports = DotObject\n'))
.pipe(rename({ basename: 'index' }))
.pipe(gulp.dest('./'))
done()
})
gulp.task('build-bower', function (done) {
gulp.src('src/dot-object.js')
.pipe(hf.header('src/header.tpl'))
.pipe(hf.footer('src/footer.tpl'))
.pipe(beautify({ indentSize: 2 }))
.pipe(gulp.dest(DEST))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(DEST))
done()
})
gulp.task('dist', gulp.parallel('lint', 'build-node', 'mocha', 'build-bower'))
gulp.task('test', gulp.parallel('lint', 'build-node', 'mocha'))
gulp.task('default', gulp.parallel('test'))