This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
forked from TomFrost/Jexl
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
67 lines (63 loc) · 1.57 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
62
63
64
65
66
67
/*
* Jexl
* Copyright (c) 2015 TechnologyAdvice
*/
var browserify = require('browserify'),
gulp = require('gulp'),
transform = require('vinyl-transform'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
path = require('path'),
coverageEnforcer = require("gulp-istanbul-enforcer"),
istanbul = require('gulp-istanbul'),
mocha = require('gulp-mocha');
gulp.task('dist', function() {
// transform regular node stream to gulp (buffered vinyl) stream
var browserified = transform(function(filename) {
var b = browserify({
paths: [path.dirname(filename)]
});
b.require(path.basename(filename, '.js'));
return b.bundle();
});
return gulp.src('./lib/Jexl.js')
.pipe(browserified)
.pipe(uglify())
.pipe(rename({
basename: 'jexl',
extname: '.min.js'
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('coverage-test', function(cb) {
var passThresholds = {
thresholds : {
statements : 95,
branches : 88,
lines : 95,
functions : 92
},
coverageDirectory : 'coverage',
rootDirectory : ''
};
gulp.src(['test/**/*.js'])
.pipe(mocha())
.on('end', function() {
gulp.src(['lib/**/*.js'])
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire())
.on('finish', function() {
gulp.src(['test/**/*.js'])
.pipe(mocha({reporter: 'min'}))
.pipe(istanbul.writeReports({
reporters: ['json', 'lcovonly']
}))
.on('finish', function() {
gulp.src('.')
.pipe(coverageEnforcer(passThresholds))
.on('end', cb);
});
});
});
});
gulp.task('default', ['dist']);