-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
73 lines (57 loc) · 1.67 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
'use strict';
var path = require('path'),
gulp = require('gulp'),
extend = require('extend'),
karma = require('karma').server,
karmaConfig = require('./karma.conf'),
config = require('./build.conf.js'),
plugins = require('gulp-load-plugins')();
var ciMode = false;
gulp.task('clean', function () {
return gulp
.src(config.buildFolder, {read: false})
.pipe(plugins.clean());
});
gulp.task('scripts', function () {
return gulp.src(config.srcJs)
// jshint
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.if(ciMode, plugins.jshint.reporter('fail')))
// package
.pipe(plugins.concat(config.buildJsFilename))
.pipe(plugins.header(config.closureStart))
.pipe(plugins.footer(config.closureEnd))
.pipe(plugins.header(config.banner))
.pipe(gulp.dest(config.buildFolder))
.pipe(plugins.filesize())
// minify
.pipe(plugins.uglify())
.pipe(plugins.rename({ extname: '.min.js' }))
.pipe(gulp.dest(config.buildFolder))
.pipe(plugins.filesize())
.on('error', plugins.util.log);
});
gulp.task('test', function () {
karmaConfig({
set: function (testConfig) {
extend(testConfig, {
singleRun: ciMode,
autoWatch: !ciMode,
browsers: ['PhantomJS']
});
karma.start(testConfig, function (exitCode) {
plugins.util.log('Karma has exited with ' + exitCode);
process.exit(exitCode);
});
}
});
});
gulp.task('watch', function () {
return gulp.watch(config.srcJs, ['scripts']);
});
gulp.task('ci', function () {
ciMode = true;
return gulp.start(['clean', 'scripts', 'test']);
});
gulp.task('default', ['scripts']);