Created
October 20, 2014 17:06
-
-
Save nicolashery/8e6baed6d3fd6bcde8d5 to your computer and use it in GitHub Desktop.
Gulpfile for JSHint on a React app with watch, JSX error logging, and cache
This file contains 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 react = require('gulp-react'); | |
var jshint = require('gulp-jshint'); | |
var cache = require('gulp-cached'); | |
var jsFiles = [ | |
'src/**/*.js', | |
'test/**/*.js', | |
'*.js' | |
]; | |
gulp.task('jshint', function() { | |
var stream = gulp.src(jsFiles) | |
.pipe(cache('jshint')) | |
.pipe(react()) | |
.on('error', function(err) { | |
console.error('JSX ERROR in ' + err.fileName); | |
console.error(err.message); | |
this.end(); | |
}) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish')); | |
if (process.env.CI) { | |
stream = stream.pipe(jshint.reporter('fail')); | |
} | |
return stream; | |
}); | |
gulp.task('jshint-watch', ['jshint'], function(cb){ | |
console.log('Watching files for changes...'); | |
gulp.watch(jsFiles, ['jshint']); | |
}); | |
gulp.task('default', ['jshint']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment