Skip to content

Instantly share code, notes, and snippets.

@diffused
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diffused/1bd32ae3c48294052828 to your computer and use it in GitHub Desktop.
Save diffused/1bd32ae3c48294052828 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
gulp.task('default', ['watchJs', 'watchTests']);
// make sure you do not start a path with ./
// there's some bug in gaze that causes globs with ./ to not fire
var unitTestPaths = [
'tests/**/*_tests.js'
];
var jsPaths = [
'build/app/js/**/*.js'
];
function mochaPipe() {
return $.mocha({ reporter: 'spec' });
}
gulp.task('watchJs', function() {
$.watch({
glob: jsPaths,
read: false
},
function() {
gulp.start('allUnitTests');
}
);
});
//
gulp.task('watchTests', function() {
$.watch({
glob: unitTestPaths
},
function(files) {
return files
.pipe(mochaPipe())
;
});
});
gulp.task('allUnitTests', function() {
return gulp.src(unitTestPaths, {read: false})
.pipe(mochaPipe())
;
});
{
"name": "gulp-mocha-watch",
"version": "0.2.0",
"dependencies": {},
"devDependencies": {
"chai": "^1.9.1",
"gulp": "^3.8.7",
"gulp-load-plugins": "^0.5.3",
"gulp-mocha": "^1.0.0",
"gulp-watch": "^0.6.9"
},
"engines": {
"node": ">=0.10.26"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment