-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
53 lines (47 loc) · 1.45 KB
/
gulpfile.js
File metadata and controls
53 lines (47 loc) · 1.45 KB
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
'use strict';
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
header = require('gulp-header'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
istanbul = require('gulp-istanbul');
var pkg = require('./package.json'),
banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @author <%= pkg.author %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('jshint', function () {
return gulp.src('src/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build', function () {
return gulp.src('src/*.js')
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename({
suffix: '.min',
}))
.pipe(gulp.dest('dist'));
});
gulp.task('mocha', function (cb) {
gulp.src('src/*.js')
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(['tests/*.js'])
.pipe(mocha())
.pipe(istanbul.writeReports())
.on('end', cb);
});
});
gulp.task('tests', ['jshint', 'mocha']);
gulp.task('default', ['jshint', 'mocha', 'build']);