-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
123 lines (101 loc) · 3.03 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
'use strict';
const gulp = require('gulp');
const gulpEslint = require('gulp-eslint');
const gulpJsonlint = require('gulp-jsonlint');
const gulpDebug = require('gulp-debug');
const gulpJasmine = require('gulp-jasmine');
const gulpIstanbul = require('gulp-istanbul');
const gulpSequence = require('gulp-sequence');
const argv = require('yargs').argv;
const guppy = require('git-guppy')(gulp);
const JasmineConsoleReporter = require('jasmine-console-reporter');
const reporter = new JasmineConsoleReporter({
colors: 1, // (0|false)|(1|true)|2
cleanStack: 1, // (0|false)|(1|true)|2|3
verbosity: 2, // (0|false)|1|2|(3|true)|4
listStyle: 'indent', // "flat"|"indent"
activity: false
});
//const FUNCTIONS_COVERAGE_THRESHOLD = 1;
const allOfMyLintFiles = [
'!node_modules/**',
'!**/node_modules/**',
'!coverage/**',
'!Gulpfile.js',
'**/*.js'
];
const allOfMyTestFiles = [
'!node_modules/**',
'!**/node_modules/**',
'!coverage/**',
'**/*.spec.js'
];
const allOfMyCoverageFiles = [
'!node_modules/**',
'!server.js',
'!coverage/**',
'!Gulpfile.js',
'!**/*.spec.js',
'**/*.js'
];
const allOfMyJsonFiles = [
'!node_modules/**',
'!coverage/**',
'**/*.json'
];
let source = argv.source;
// option (-c or --coverage--off) to turn off istanbul coverage reporting for debugging unit tests. istanbul would instrument code and distort line numbers.
let coverageOff = argv.c || argv.coverageOff;
gulp.task('lint', function lint () {
return gulp.src(source || allOfMyLintFiles)
.pipe(gulpDebug({ title: 'lint:' }))
.pipe(gulpEslint())
.pipe(gulpEslint.format()); //pipe(gulpEslint.failAfterError());
});
gulp.task('json-lint', function jsonlint () {
return gulp.src(allOfMyJsonFiles)
//.pipe(gulpDebug({ title: 'json-lint' }))
.pipe(gulpJsonlint())
.pipe(gulpJsonlint.failAfterError())
.pipe(gulpJsonlint.reporter());
});
gulp.task('pre-jasmine', function preJasmine () {
let pipes = gulp.src(source || allOfMyCoverageFiles);
if (!coverageOff) {
pipes = pipes.pipe(gulpIstanbul({includeUntested: true}));
}
pipes.pipe(gulpIstanbul.hookRequire());
return pipes;
});
gulp.task('jasmine', ['pre-jasmine'], function jasmine () {
let pipes = gulp.src(source || allOfMyTestFiles)
.pipe(gulpDebug({ title: 'jasmine:' }))
.pipe(gulpJasmine({
verbose: true,
timeout: 1000,
includeStackTrace: true,
reporter: reporter
}));
if (!coverageOff) {
pipes = pipes.pipe(gulpIstanbul.writeReports());
}
return pipes;
});
//add lint back when it's cleaner: gulpSequence('lint', 'jasmine'));
gulp.task('test', gulpSequence('lint', 'json-lint', 'jasmine'));
gulp.task('watch', ['test'], function watch () {
gulp.watch(allOfMyTestFiles, ['test']);
});
gulp.task('debug', function debug () {
return gulp.src(allOfMyTestFiles).
pipe(gulpDebug({
title: 'jasmine:'
})).
pipe(gulpJasmine({
verbose: true,
timeout: 1000,
includeStackTrace: true
}));
});
gulp.task('pre-commit', ['test']);
gulp.task('default', ['test']);