forked from iandotkelly/nlf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (59 loc) · 1.5 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
/**
* @description - gulp build file
*
* @copyright Ian Kelly 2015
*/
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var cover = require('gulp-coverage');
var coveralls = require('gulp-coveralls');
// set coveralls environmental variable
process.env['COVERALLS_REPO_TOKEN'] = 'rCIR66aQA8jUA7Berlh1PHd917mjMt4hU';
/**
* Linting task
*/
gulp.task('lint', function() {
return gulp.src(['lib/**/*.js', 'test/unit/**/*.js', 'gulpfile.js'])
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
/**
* Task for developer test and coverage report
*/
gulp.task('test', ['lint'], function () {
return gulp.src(['lib/**/*.js', 'test/unit/**/*.js'], { read: false })
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
.pipe(cover.instrument({
pattern: ['lib/**/*.js']
}))
.pipe(mocha())
.pipe(cover.gather())
.pipe(cover.format())
.pipe(gulp.dest('reports'));
});
/**
* Task for travis-ci which pipes coverage to coveralls
*/
gulp.task('test-coveralls', ['lint'], function() {
return gulp.src(['lib/**/*.js', 'test/unit/**/*.js'], { read: false })
.pipe(cover.instrument({
pattern: ['lib/**/*.js']
}))
.pipe(mocha())
.pipe(cover.gather())
.pipe(cover.format({
reporter: 'lcov'
}))
.pipe(coveralls());
});
gulp.task('default', ['lint', 'test']);
gulp.task('travis', ['lint', 'test-coveralls']);