-
Notifications
You must be signed in to change notification settings - Fork 69
/
gulpfile.js
54 lines (47 loc) · 1.4 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var header = require('gulp-header');
var karma = require('gulp-karma');
var fs = require('fs');
var pkg = require('./package.json');
var paths = {
src: 'src/' + pkg.name + '.js',
spec: 'spec/'
};
// Using a banner that is stored in a file to make it easier to work with.
try {
var banner = fs.readFileSync('banner.txt');
} catch(e) {
throw new Error('There was an error reading in the banner.');
}
gulp.task('default', ['watch']);
gulp.task('lint', function() {
gulp.src(paths.src)
.pipe(jshint())
.pipe(jshint.reporter('checkstyle'))
.pipe(jshint.reporter('fail'));
});
gulp.task('build', ['lint', 'test'], function() {
gulp.src(paths.src)
.pipe(uglify())
.pipe(concat(pkg.name + '.min.js'))
.pipe(header(banner, { pkg: pkg, buildDate: gutil.date(new Date(), 'yyyy-mm-dd') }))
.pipe(gulp.dest('build'));
});
gulp.task('test', function() {
gulp.src(paths.spec + '**/*-spec.js')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}));
});
gulp.task('watch', function() {
gulp.src(paths.spec + '**/*-spec.js')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'watch'
}));
});