@@ -11,17 +11,9 @@ const webpackTestConfig = require('./spec/webpack.test.config');
1111const webpackConfig = require ( './webpack.config' ) ;
1212const plumber = require ( 'gulp-plumber' ) ;
1313const gutil = require ( 'gulp-util' ) ;
14+ const eslint = require ( 'gulp-eslint' ) ;
1415const nodemon = require ( 'nodemon' ) ;
1516
16- function filterStack ( stack ) {
17- const jasmineCorePath = require . resolve ( 'jasmine-core' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
18- const superTestPath = require . resolve ( 'supertest' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
19- const superAgentPath = require . resolve ( 'superagent' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
20- return stack . split ( '\n' ) . filter ( function ( stackLine ) {
21- return stackLine . indexOf ( jasmineCorePath ) === - 1 && stackLine . indexOf ( superTestPath ) === - 1
22- && stackLine . indexOf ( superAgentPath ) === - 1
23- } ) . join ( '\n' ) ;
24- }
2517const terminalReporter = new TerminalReporter ( {
2618 showColors : true ,
2719 includeStackTrace : true ,
@@ -30,6 +22,25 @@ const terminalReporter = new TerminalReporter({
3022 }
3123} ) ;
3224
25+ const filesToLint = [
26+ 'client/**/*.js' ,
27+ 'server/**/*.js' ,
28+ 'spec/client/**/*.js' ,
29+ 'spec/server/**/*.js'
30+ ] ;
31+
32+ gulp . task ( 'runDev' , [
33+ 'webpackWatch' ,
34+ 'serverWatch'
35+ ] ) ;
36+
37+ gulp . task ( 'lint' , function ( ) {
38+ return gulp . src ( filesToLint )
39+ . pipe ( eslint ( ) )
40+ . pipe ( eslint . format ( ) )
41+ . pipe ( eslint . failAfterError ( ) ) ;
42+ } ) ;
43+
3344gulp . task ( 'serverWatch' , function ( ) {
3445 nodemon ( {
3546 script : './server/utilities/runServer.js' ,
@@ -43,10 +54,6 @@ gulp.task('webpackWatch', function () {
4354 . pipe ( gulp . dest ( 'public/' ) ) ;
4455} ) ;
4556
46- gulp . task ( 'runDev' , [
47- 'webpackWatch' ,
48- 'serverWatch'
49- ] ) ;
5057
5158gulp . task ( 'jasmine' , function ( ) {
5259 process . env . NODE_ENV = 'test' ;
@@ -69,7 +76,7 @@ gulp.task('serverSpecs', function () {
6976} ) ;
7077
7178gulp . task ( 'specs' , function ( ) {
72- runSequence ( 'unitSpecs' , 'serverSpecs' , function ( err ) {
79+ runSequence ( 'unitSpecs' , 'serverSpecs' , 'lint' , function ( err ) {
7380 // avoids the cluttering error runSequence throws
7481 if ( err ) {
7582 process . exit ( 1 )
@@ -98,4 +105,14 @@ function bundleAssets(config, options) {
98105 . on ( 'error' , function ( err ) {
99106 gutil . log ( gutil . colors . red ( 'Bundling test assets failed' ) , gutil . colors . red ( err ) ) ;
100107 } ) ;
108+ }
109+
110+ function filterStack ( stack ) {
111+ const jasmineCorePath = require . resolve ( 'jasmine-core' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
112+ const superTestPath = require . resolve ( 'supertest' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
113+ const superAgentPath = require . resolve ( 'superagent' ) . split ( path . sep ) . slice ( 0 , - 1 ) . join ( path . sep ) ;
114+ return stack . split ( '\n' ) . filter ( function ( stackLine ) {
115+ return stackLine . indexOf ( jasmineCorePath ) === - 1 && stackLine . indexOf ( superTestPath ) === - 1
116+ && stackLine . indexOf ( superAgentPath ) === - 1
117+ } ) . join ( '\n' ) ;
101118}
0 commit comments