-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (64 loc) · 1.92 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
68
69
70
71
72
73
74
75
var pkg = require('./package.json');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jshintStylish = require('jshint-stylish');
var header = require('gulp-header');
var karma = require('karma').server;
var ngAnnotate = require('gulp-ng-annotate');
var path = require('path');
var runSequence = require('run-sequence');
var uglify = require('gulp-uglify');
var banner = [
'/**',
' * <%= pkg.name %> v<%= pkg.version %> - <%= releaseDate %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.licenses[0].type %> - <%= pkg.licenses[0].description %>',
' */',
''
].join('\n');
/**************************************************************
Tasks
/*************************************************************/
gulp.task('build', function(done) {
return runSequence('clean', 'uglify', done);
});
gulp.task('clean', function() {
return gulp.src('./dist', {
read: false
}).pipe(clean());
});
gulp.task('default', function() {
return runSequence('jshint', watch);
});
gulp.task('jshint', function() {
return gulp.src(['./src/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish));
});
gulp.task('karma', function(done) {
return karma.start({
configFile: path.resolve('./test-karma-config.js')
}, done);
});
gulp.task('test', function(done) {
return runSequence('jshint', 'karma', done);
});
gulp.task('uglify', function(done) {
return gulp.src(['./bower_components/cookies-js/src/cookies.js', './src/**/*.js'])
.pipe(concat('cookies.js'))
.pipe(ngAnnotate())
.pipe(header(banner, {
pkg: pkg,
releaseDate: (new Date()).toISOString().slice(0, 10)
}))
.pipe(gulp.dest('./dist'))
.pipe(concat('cookies.min.js'))
.pipe(uglify())
.pipe(header(banner, {
pkg: pkg,
releaseDate: (new Date()).toISOString().slice(0, 10)
}))
.pipe(gulp.dest('./dist'));
});