-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
97 lines (88 loc) · 2.81 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
/*
* loopback-webpack-plugin
* https://github.com/SimonDegraeve/loopback-webpack-plugin
*
* Copyright 2014, Simon Degraeve
* Licensed under the MIT license.
*/
'use strict';
var exec = require('child_process').exec,
gulp = require('gulp'),
watch = require('gulp-watch'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
plumber = require('gulp-plumber'),
coveralls = require('gulp-coveralls'),
complexity = require('gulp-complexity'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
jscsStylish = require('jscs-stylish'),
jshintStylish = require('jshint-stylish'),
paths = {
'src.scripts': 'lib/**/*.js',
'src.tests': 'lib/**/__test__/*.js',
'src.fixtures': 'lib/**/fixtures/**',
'src.tests.loader': 'test-loader.js'
};
gulp.task('check-updates', function(done) {
exec('./node_modules/.bin/npm-check-updates', function(error, stdout, stderr) {
if (stdout.indexOf('All dependencies match the latest package versions :)') === -1) {
error = new Error('Dependencies can be updated.');
console.log(stdout);
}
done(error);
});
});
gulp.task('apply-updates', function(done) {
exec('./node_modules/.bin/npm-check-updates -u', function(error, stdout, stderr) {
if (stdout.indexOf('All dependencies match the latest package versions :)') !== -1) {
return done(error);
}
if (stdout.indexOf('package.json upgraded') === -1) {
error = new Error('Fail upgrading dependencies.');
console.log(stdout);
}
done(error);
});
});
gulp.task('coveralls', function() {
gulp.src('./coverage/**/lcov.info')
.pipe(coveralls());
});
gulp.task('test', ['lint'], function(done) {
gulp.src([paths['src.scripts'], '!' + paths['src.tests'], '!' + paths['src.fixtures']])
.pipe(istanbul({
includeUntested: true
}))
.on('finish', function() {
gulp.src(paths['src.tests.loader'], {read: false})
// .pipe(plumber())
.pipe(mocha())
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: ['lcov', 'text', 'text-summary']
}))
.on('end', done);
});
});
gulp.task('watch:test', ['test'], function() {
watch([paths['src.scripts'], paths['src.tests']], {name: 'src.tests', read: false}, function() {
gulp.start('test');
});
});
gulp.task('lint', function() {
return gulp.src([paths['src.scripts'], paths['src.tests'], '!' + paths['src.fixtures']])
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish))
.pipe(jshint.reporter('fail'))
.pipe(jscs())
.pipe(jscs.reporter(jscsStylish))
.pipe(jscs.reporter('fail'))
.pipe(complexity({
cyclomatic: [5, 15, 25],
halstead: [15, 20, 25],
maintainability: 100,
breakOnErrors: false
}));
});
gulp.task('default', ['test']);