-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gulpfile.js
62 lines (57 loc) · 2.1 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
/**
* Created by nikolai on 10/21/16.
*/
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var rimraf = require('gulp-rimraf');
var env = require('gulp-env');
var runSequence = require('run-sequence');
var istanbul = require('gulp-istanbul');
var isparta = require('isparta');
var mocha = require('gulp-mocha-co');
gulp.task('clean', function () {
return gulp.src(['.coverdata', '.debug', '.coverrun'], {read: false})
.pipe(rimraf());
});
gulp.task('lint', ['clean'], function () {
return gulp.src(['**/*.js', '!**/node_modules/**', '!**/server/migration/**', '!coverage/**/*.js'])
.pipe(jshint({lookup: true}))
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('set_unit_env_vars', function () {
var POSTGRES_USER = process.env.POSTGRES_USER;
var POSTGRES_PASSWORD = process.env.POSTGRES_PASSWORD;
var POSTGRES_DB = process.env.POSTGRES_DB;
env({
vars: {
POSTGRES_USER: POSTGRES_USER,
POSTGRES_PASSWORD: POSTGRES_PASSWORD,
POSTGRES_DB: POSTGRES_DB
}
});
});
gulp.task('unit_pre', function () {
return gulp.src(['**/*.js', '!index.js', '!**/*.spec.js', '!**/node_modules/**/*.js', '!.debug/**/*.js', '!gulpfile.js', '!coverage/**/*.js'])
.pipe(istanbul({ // Covering files
instrumenter: isparta.Instrumenter,
includeUntested: true
}))
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function () {
gulp.src(['**/*.unit.spec.js', '!**/node_modules/**/*.js'], {read: false})
.pipe(mocha({reporter: 'spec', timeout: '10000'}))
.pipe(istanbul.writeReports({
reporters: ['lcov'],
reportOpts: {dir: 'coverage'}
}))
.once('end', function () {
process.exit();
});
});
});
gulp.task('unit_test', function (callback) {
runSequence('set_unit_env_vars',
'unit_pre',
callback);
});