Created
February 5, 2014 18:58
-
-
Save kaiquewdev/8830646 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var spawn = require('child_process').spawn; | |
var gutil = require('gulp-util'); | |
var gmocha = require('gulp-mocha'); | |
var gwatch = require('gulp-watch'); | |
var gbatch = require('gulp-batch'); | |
function testsTaskHandler ( callback ) { | |
var paths = [ | |
'./test/**/*.test.js', | |
'--timeout 50000', | |
'--reporter spec' | |
]; | |
var mocha = spawn('mocha', paths); | |
function print ( data ) { | |
process.stdout.write( data.toString('utf-8') ); | |
} | |
mocha | |
.stdout | |
.on('data', print); | |
mocha | |
.stderr | |
.on('data', print); | |
mocha | |
.on('close', callback); | |
} | |
gulp.task( 'tests', testsTaskHandler ); | |
function watchTaskHandler ( callback ) { | |
var paths = [ | |
'./modules/**/*.js', | |
'./models/**/*.js', | |
'./routes/**/*.js', | |
'./middlewares/**/*.js', | |
'./test/**/*.test.js', | |
]; | |
var srcOpts = { read: false }; | |
function watchHandler ( events, callback ) { | |
testsTaskHandler( callback ); | |
} | |
gulp.watch( paths, gbatch( watchHandler ) ); | |
} | |
gulp.task( 'watch', watchTaskHandler ); | |
gulp.task('default', [ 'watch' ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment