-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
74 lines (66 loc) · 1.69 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
/**
* @file
*
* ### Responsibilities
* - automate common tasks using gulp
*
* Scaffolded with generator-microjs v0.1.2
*
* @author Daniel Lamb <[email protected]>
*/
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
complexity = require('gulp-complexity'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
karma = require('gulp-karma'),
jsdoc = require('gulp-jsdoc'),
fs = require('fs'),
source = 'console.style.js',
sourceMin = 'console.style.min.js',
specs = 'test/spec/*.spec.js',
karmaConf = 'test/karma.conf',
umdWrapper = fs.readFileSync('./.umd');
gulp.task('lint', function () {
return gulp.src([source, specs])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('gpa', function () {
return gulp.src([source, specs])
.pipe(complexity({
cyclomatic: [8],
halstead: [13],
maintainability: [100]
}));
});
gulp.task('test', function () {
return gulp.src([source, specs])
.pipe(karma({
configFile: karmaConf + '.js'
}));
});
gulp.task('min', function () {
return gulp.src(source)
.pipe(rename(sourceMin))
.pipe(uglify({
outSourceMap: true
}))
.pipe(replace(/(.*)/, umdWrapper))
.pipe(gulp.dest('.'));
});
gulp.task('test-min', ['min'], function () {
return gulp.src([sourceMin, specs])
.pipe(karma({
configFile: karmaConf + '.js',
reporters: ['dots']
}));
});
gulp.task('docs', function () {
return gulp.src(source)
.pipe(jsdoc('./docs'));
});
gulp.task('default', ['lint', 'gpa', 'test', 'test-min', 'docs']);