Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
69 lines (60 loc) · 1.67 KB
/
Copy pathgulpfile.js
File metadata and controls
69 lines (60 loc) · 1.67 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
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var path = require('path');
var paths = {
mochaTests: ['test/**/*[Tt]ests.js'],
filesToLint: ['./lib/**/*.js', './test/**/*.js', 'gulpfile.js'],
sourceJSFilesForCodeCoverage: ['./lib/**/*.js']
};
gulp.task('lint-watch', ['lint'], function () {
$.watch(paths.filesToLint, function () {
gulp.start('lint');
});
});
gulp.task('lint', function () {
return gulp.src(paths.filesToLint)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('unitTest', function() {
return gulp.src(paths.mochaTests, { read: false })
.pipe($.mocha({
reporter: 'spec',
slow: 500,
timeout: 5000,
//globals: {}
}));
})
gulp.task('test', ['unitTest'], function () {
gulp.start('lint');
});
gulp.task('coverage', function (cb) {
gulp.src(paths.sourceJSFilesForCodeCoverage)
.pipe($.istanbul()) // Covering files
.pipe($.istanbul.hookRequire())
.on('finish', function () {
gulp.src(paths.mochaTests, { read: false })
.pipe($.mocha({
reporter: 'dot',
timeout: 5000
}))
.pipe($.istanbul.writeReports()) // Creating the reports after tests ran
.on('finish', function () {
process.chdir(__dirname);
cb();
});
});
});
gulp.task('coveralls', ['coverage'], function () {
return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
.pipe($.coveralls())
.on('error', function(err) {
console.error(err);
})
.on('end', function () {
console.log("Coverage published to coveralls.io");
});
});
gulp.task('default', ["test"]);