-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (97 loc) · 2.5 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
(function() {
'use strict';
/*
* aliases
* gulp: gulp streaming build system
* $: namespace for gulp plugins
*/
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
// project information
project = require('./package.json'),
// karma test server
karmaServer = require('karma').Server;
/*
* gulp plugins available
*
* $.rename: gulp-rename
* $.uglify: gulp-uglify
* $.karma: gulp-karma
* $.concatUtil: gulp-concat-util
* $.eslint: gulp-eslint
*/
/*
* project paths
*/
var paths = {
src: './src/' + project.title + '.js',
spec: './test/' + project.title + '.spec.js',
output: './dist'
}
/*
* project banner for dist version
*/
var banner = '/*' +
'\n * ' + project.title + ' - v' + project.version +
'\n * ' + project.url +
'\n * ' + project.copyright + ' (c) ' + project.author + ' - ' + project.license + ' License' +
'\n*/\n\n';
/*
* checks syntax in source files
*
* gulp lint:src
*/
gulp.task('lint:src', function() {
return gulp.src(paths.src)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
/*
* checks syntax in test files
*
* gulp lint:src
*/
gulp.task('lint:spec', function() {
return gulp.src(paths.spec)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
/*
* groups lint tasks
*
* gulp lint
*/
gulp.task('lint', [ 'lint:src', 'lint:spec' ]);
/*
* checks general syntax and run tests on source files
*
* gulp test
*/
gulp.task('test', [ 'lint' ], function(done) {
var server = new karmaServer({
configFile: __dirname + '/test/karma.conf.js',
singleRun: true
}, done);
return server.start();
});
/*
* run tests and creates distribution files
*
* gulp build
*/
gulp.task('build', [ 'test' ], function () {
return gulp.src(paths.src)
.pipe($.concatUtil.header(banner))
.pipe(gulp.dest(paths.output))
.pipe($.uglify())
.pipe($.rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.output));
});
/*
* default task */
gulp.task('default', [ 'build' ]);
})();