-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (62 loc) · 1.76 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
'use strict';
var gulp = require( 'gulp-param' )( require( 'gulp' ), process.argv );
var jshint = require( 'gulp-jshint' );
var eslint = require( 'gulp-eslint' );
var stylish = require( 'jshint-stylish' );
var mocha = require( 'gulp-mocha' );
var coverage = require( 'gulp-coverage' );
var exit = require( 'gulp-exit' );
var exec = require( 'child_process' ).exec;
gulp.task( 'jslint', function () {
return gulp.src( [ './*.js', './test/**/*.js' ] )
.pipe( jshint() )
.pipe( jshint.reporter( stylish ) )
.pipe( jshint.reporter( 'fail' ) );
} );
gulp.task( 'eslint', function () {
return gulp.src( [ './*.js', './test/**/*.js' ] )
.pipe( eslint() )
.pipe( eslint.format() )
.pipe( eslint.failOnError() );
} );
gulp.task( 'dropDb', function () {
exec( 'make dropdb', function ( err ) {
return err;
} );
} );
gulp.task( 'test', [ 'jslint', 'eslint', 'dropDb' ], function ( pathSource, dontExit ) {
var sourceFile = './test/**/*.js';
var processExit = '';
if ( pathSource ) {
sourceFile = pathSource;
}
if ( !dontExit ) {
processExit = exit();
}
return gulp.src( sourceFile, {
'read' : false,
'base' : '/'
} )
.pipe(
mocha( {
'reporter' : 'spec'
} )
)
.pipe( coverage.instrument( {
'pattern' : [ './api/**/*.js', './db/**/*.js', './lib/**/*.js' ],
'debugDirectory' : 'debug'
} ) )
.pipe( coverage.gather() )
.pipe( coverage.format( [ {
'reporter' : 'html',
'outFile' : 'coverage.html'
} ] ) )
.pipe( gulp.dest( 'reports' ) )
.pipe( processExit );
} );
gulp.task( 'watch', function () {
gulp.watch( [ './test/**/*.js', 'gulpfile.js' ], function ( event ) {
console.log( 'File ' + event.path + ' was ' + event.type + ', running tasks...' );
gulp.start( 'test --dontExit true' );
} );
} );