-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
78 lines (72 loc) · 2.62 KB
/
gulpfile.js
File metadata and controls
78 lines (72 loc) · 2.62 KB
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
(function() {
'use strict';
var config = require('./config');
var gulp = require('gulp');
var gulpUtil = require('gulp-util');
var del = require('del');
var coverageEnforcer = require('gulp-istanbul-enforcer');
var jshint = require('gulp-jshint');
var jshintStylish = require('jshint-stylish');
var jscs = require('gulp-jscs');
var jscsStylish = require('gulp-jscs-stylish');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var header = require('gulp-header');
var fs = require('fs');
var karma = require('gulp-karma');
gulp.task('clean', function(deleteDone) {
del.sync([
'dist',
'temp'
]);
deleteDone();
});
gulp.task('karma', function() {
return gulp.src([])
.pipe(karma({configFile: 'karma.conf.js', action: 'run'}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
})
.pipe(coverageEnforcer({
thresholds : {
statements: 100,
branches: 96.8,
functions: 100,
lines: 100
},
coverageDirectory : 'coverage',
rootDirectory : 'temp'
}));
});
gulp.task('compile', ['clean', 'karma'], function() {
return gulp.src('source/**/*.js')
.pipe(jshint())
.pipe(jscs())
.on('error', function() {
// do not stop on error, jshint reporter will abort the build
})
.pipe(jscsStylish.combineWithHintResults())
.pipe(jshint.reporter(jshintStylish))
.pipe(config.build.failOnStyleErrors ? jshint.reporter('fail') : gulpUtil.noop())
.pipe(concat('ai-logger.js'))
.pipe(header(fs.readFileSync('license_prefix.txt', 'utf8')))
.pipe(gulp.dest('dist'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(rename('ai-logger.min.js'))
.pipe(header(fs.readFileSync('license_prefix.txt', 'utf8')))
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['clean'], function() {
config.build.minifyCode = true;
config.build.failOnStyleErrors = true;
config.karma.browsers = ['PhantomJS'];
config.karma.reporters = ['progress', 'coverage'];
config.karma.captureTimeout = 60000;
gulp.run('compile');
});
gulp.task('default', ['build']);
}());