-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
62 lines (55 loc) · 1.71 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
'use strict';
const gulp = require('gulp'),
istanbul = require('gulp-istanbul'),
istanbulHarmony = require('istanbul-harmony'),
mocha = require('gulp-mocha'),
eslint = require('gulp-eslint');
const sockFiles = ['*.js', '!./gulpfile.js', '**/lib/**/*.js', '!node_modules/**', '!test/**'],
sockTests = ['test/**/*.js'];
const CI = process.env.CI === 'true';
const testReporter = CI ? 'spec': 'dot';
/**
* Run all js files through eslint and report status.
*/
gulp.task('lintCore', () => {
return gulp.src(sockFiles)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/**
* Run all tests through eslint and report status.
*/
gulp.task('lintTests', () => {
return gulp.src(sockTests)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/**
* Run code coverage instrumented tests
*/
gulp.task('test', ['lintCore', 'lintTests'], (done) => {
gulp.src(sockFiles)
// Instrument code files with istanbulHarmony
.pipe(istanbul({
instrumenter: istanbulHarmony.Instrumenter,
includeUntested: true
}))
// hook require function for complete code coverage
.pipe(istanbul.hookRequire())
.on('finish', () => {
// Run all tests
gulp.src(sockTests)
.pipe(mocha({
reporter: testReporter
}))
.on('error', done)
// Write code coverage reports
.pipe(istanbul.writeReports())
.on('finish', done);
});
});
// Meta tasks
gulp.task('default', ['lint'], () => 0);
gulp.task('lint', ['lintCore', 'lintTests'], () => 0);