forked from christian-fei/Simple-Jekyll-Search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (48 loc) · 1.33 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
60
61
var gulp = require('gulp')
, browserify = require('gulp-browserify')
, rename = require('gulp-rename')
, using = require('gulp-using')
, concat = require('gulp-concat')
, uglify = require('gulp-uglify')
, karma = require('gulp-karma')
, jshint = require('gulp-jshint')
var ENTRYPOINT = {
JS: 'src/index.js'
}
var FILES = {
JS: 'src/**/*.js',
TEST: 'src/**/*.test.js'
}
gulp.task('default', ['js:src','lint'])
gulp.task('watch',['default', 'js:test:unit'], function(){
gulp.watch(['!'+ENTRYPOINT.JS,FILES.TEST], ['js:src','js:test:unit'])
gulp.watch([FILES.JS], ['lint'])
gulp.watch([FILES.TEST], ['js:test:unit'])
})
gulp.task('lint', function() {
return gulp.src(['src/**/*.js','!'+FILES.TEST])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
})
gulp.task('js:src', function() {
gulp.src(ENTRYPOINT.JS)
.pipe(browserify({
debug : !process.env.PROD
}))
.pipe(rename('jekyll-search.js'))
.pipe(gulp.dest('./dest/'))
.pipe(uglify({mangle: false,compress:true}))
.pipe(rename('jekyll-search.min.js'))
.pipe(gulp.dest('./dest/'))
})
gulp.task('js:test:unit', function() {
return gulp.src([FILES.TEST])
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
this.emit('end')
throw err
})
})