Skip to content

Commit f10d98a

Browse files
committed
Don't allow the dev task to exit on jshint errors
1 parent 9796bd0 commit f10d98a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

gulpfile.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ var jshint = require('gulp-jshint');
55
var gutil = require('gulp-util');
66
var livereload = require('gulp-livereload');
77

8+
// Command line option:
9+
// --fatal=[warning|error|off]
10+
var fatalLevel = require('yargs').argv.fatal;
11+
12+
var ERROR_LEVELS = ['error', 'warning'];
13+
14+
function isFatal(level) {
15+
return ERROR_LEVELS.indexOf(level) <= ERROR_LEVELS.indexOf(fatalLevel || 'error');
16+
}
17+
818
// Handle an error based on its severity level.
919
// Log all levels, and exit the process for fatal levels.
1020
function handleError(level, error) {
1121
gutil.log(gutil.colors.red(error.message));
12-
if (level === 'error') {
22+
if (isFatal(level)) {
1323
process.exit(1);
1424
}
1525
}
@@ -48,6 +58,10 @@ gulp.task('libs', function() {
4858
});
4959

5060
gulp.task('dev', function() {
61+
// no fatal errors during active development by default
62+
// this prevents this task from exiting unexpectedly
63+
fatalLevel = fatalLevel || 'off';
64+
5165
livereload.listen();
5266
gulp.watch('duckhunt/*.js', ['duckhunt']);
5367
gulp.watch('lib/*.js', ['libs']);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"gulp-jshint": "^1.11.0",
2626
"gulp-livereload": "^3.8.0",
2727
"gulp-uglify": "^1.2.0",
28-
"gulp-util": "^3.0.5"
28+
"gulp-util": "^3.0.5",
29+
"yargs": "^3.10.0"
2930
}
3031
}

0 commit comments

Comments
 (0)