forked from RemiAWE/ng-flat-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
112 lines (102 loc) · 2.88 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
'use strict';
var es = require('event-stream');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var karmaServer = require('karma').Server;
var eslint = require('gulp-eslint');
var paths = {
src: {
html: __dirname + '/src/templates/**/*.html',
js: __dirname + '/src/js/**/*.js',
tests: __dirname + '/tests/**/*.js',
scss: __dirname + '/src/scss/**/*.scss'
},
config: {
karma: __dirname + '/karma.conf.js'
},
tmp: __dirname + '/.tmp/',
dist: __dirname + '/dist/'
};
var plumberErrorHandler = {
errorHandler: function(err) {
console.log(err);
this.emit('end');
}
};
gulp.task('js', function() {
return es.merge(getTemplatesStream(), gulp.src(paths.src.js))
.pipe($.plumber(plumberErrorHandler))
.pipe($.angularFilesort())
.pipe($.ngAnnotate())
.pipe($.concat('ng-flat-datepicker.js'))
.pipe(gulp.dest(paths.dist))
.pipe($.uglify())
.pipe($.rename('ng-flat-datepicker.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('sass', function() {
return gulp.src(paths.src.scss)
.pipe($.plumber(plumberErrorHandler))
.pipe($.sass({
outputStyle: 'expanded'
}))
.pipe($.autoprefixer({
browsers: ['last 2 versions']
}))
.pipe($.rename('ng-flat-datepicker.css'))
.pipe(gulp.dest(paths.dist))
.pipe($.csso())
.pipe($.rename('ng-flat-datepicker.min.css'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('test-angular-1.3', function (done) {
new karmaServer({
configFile: __dirname + '/karma.angular-1.3.conf',
singleRun: true
}, done).start();
});
gulp.task('test-angular-1.4', function (done) {
new karmaServer({
configFile: __dirname + '/karma.angular-1.4.conf',
singleRun: true
}, done).start();
});
gulp.task('test-angular-1.5', function (done) {
new karmaServer({
configFile: __dirname + '/karma.angular-1.5.conf',
singleRun: true
}, done).start();
});
gulp.task('test', ['test-angular-1.5', 'test-angular-1.4', 'test-angular-1.3']);
gulp.task('lint', function() {
return gulp.src(['src/js/*.js', '!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/**
* Watch
*/
gulp.task('watch', function() {
$.watch([paths.src.js, paths.src.html, paths.src.tests, paths.config.karma],
$.batch(function(events, done) {
gulp.start('test', done);
}));
$.watch([paths.src.js], $.batch(function(events, done) {
gulp.start('lint', done);
}));
$.watch(paths.src.scss, $.batch(function(events, done) {
gulp.start('sass', done);
}));
$.watch([paths.src.js, paths.src.html], $.batch(function(events, done) {
gulp.start('js', done);
}));
});
gulp.task('install', ['lint', 'sass', 'js']);
gulp.task('default', ['install']);
function getTemplatesStream() {
return gulp.src(paths.src.html)
.pipe($.angularTemplatecache('templates.js', {
module: 'ngFlatDatepicker'
}));
}