-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
58 lines (50 loc) · 1.57 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
'use strict'
var gulp = require('gulp')
var exit = require('gulp-exit')
var mocha = require('gulp-mocha')
var istanbul = require('gulp-istanbul')
var jshint = require('gulp-jshint');
var del = require('del');
var gulpNSP = require('gulp-nsp');
var paths = {
src : ['src/**/*.js'],
specs : ['specs/**/*.js'],
artifact: process.env.CIRCLE_ARTIFACTS || "artifacts"
}
gulp.task('clean', function () {
return del([paths.artifact])
})
gulp.task('nsp', function (cb) {
gulpNSP({ package: __dirname + '/package.json', stopOnError: false }, cb);
});
gulp.task('test', function () {
return gulp.src(paths.specs, { read: false })
.pipe(mocha({ reporter: 'spec' }))
.pipe(exit())
})
gulp.task('pre-coverage', ['lint'], function (cb) {
return gulp.src(paths.src)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
})
gulp.task('coverage', ['nsp', 'pre-coverage'], function (cb) {
return gulp.src(paths.specs)
.pipe(mocha({ reporter: 'spec' }))
.pipe(istanbul.writeReports(
{
dir : paths.artifact + "/coverage",
reportOpts: { dir: paths.artifact + "/coverage" },
reporters : ['text', 'text-summary', 'json', 'html']
}))
.pipe(exit())
})
gulp.task('lint', function () {
return gulp.src(paths.src)
.pipe(jshint())
.pipe(jshint.reporter('gulp-jshint-html-reporter',
{
filename : paths.artifact + "/jshint" + "/jshint.html",
createMissingFolders: true
}
))
});