-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (86 loc) · 2.33 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
113
114
115
116
117
118
var gulp = require('gulp'),
karma = require('gulp-karma'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
jsdoc = require('gulp-jsdoc'),
jshint = require('gulp-jshint'),
del = require('del');
var launchKarma = function (browser) {
var testFiles = [
'src/!(_*).js',
'test/*.js' // then, include the test specs
];
// Be sure to return the stream
return gulp.src(testFiles, {read:false})
.pipe(karma({
configFile: 'karma/' + browser + '.conf.js',
action: 'run'
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
};
gulp.task('test', function(){
launchKarma('phantomjs');
});
gulp.task('test-firefox', function(){
launchKarma('firefox');
});
gulp.task('test-chrome', function(){
launchKarma('chrome');
});
gulp.task('test-safari', function(){
launchKarma('safari');
});
gulp.task('docs', function(){
del.sync('./report/docs');
return gulp.src(['src/!(_*).js'])
.pipe(jsdoc('./report/docs'));
});
gulp.task('build-prod', ['jshint'], function(){
var srcFiles = [
// 'src/_start.js',
'src/!(_*).js',
// 'src/_end.js'
];
return gulp.src(srcFiles)
.pipe(concat('ptq.min.js'))
.pipe(uglify({
mangle : true
}))
.pipe(gulp.dest('build'));
});
gulp.task('build-concat', ['jshint'], function(){
var srcFiles = [
// 'src/_start.js',
'src/!(_*).js',
// 'src/_end.js'
];
return gulp.src(srcFiles)
.pipe(concat('out.js'))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['build-concat', 'build-prod']);
gulp.task('dev', ['jshint'], function(){
var srcFiles = [
'src/!(_*).js',
];
// Be sure to return the stream
return gulp.src(srcFiles)
.pipe(concat('out.min.js'))
.pipe(gulp.dest('build'));
});
gulp.task('jshint', function() {
var testFiles = [
// 'src/_start.js',
'src/!(_*).js',
// 'src/_end.js'
];
return gulp.src(testFiles)
// .pipe(jscs()) // code style check
.pipe(concat('out.js'))
.pipe(jshint())
.pipe(jshint.reporter('cool-reporter'))
.pipe(jshint.reporter('fail'));
});