File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,21 @@ var jshint = require('gulp-jshint');
5
5
var gutil = require ( 'gulp-util' ) ;
6
6
var livereload = require ( 'gulp-livereload' ) ;
7
7
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
+
8
18
// Handle an error based on its severity level.
9
19
// Log all levels, and exit the process for fatal levels.
10
20
function handleError ( level , error ) {
11
21
gutil . log ( gutil . colors . red ( error . message ) ) ;
12
- if ( level === 'error' ) {
22
+ if ( isFatal ( level ) ) {
13
23
process . exit ( 1 ) ;
14
24
}
15
25
}
@@ -48,6 +58,10 @@ gulp.task('libs', function() {
48
58
} ) ;
49
59
50
60
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
+
51
65
livereload . listen ( ) ;
52
66
gulp . watch ( 'duckhunt/*.js' , [ 'duckhunt' ] ) ;
53
67
gulp . watch ( 'lib/*.js' , [ 'libs' ] ) ;
Original file line number Diff line number Diff line change 25
25
"gulp-jshint" : " ^1.11.0" ,
26
26
"gulp-livereload" : " ^3.8.0" ,
27
27
"gulp-uglify" : " ^1.2.0" ,
28
- "gulp-util" : " ^3.0.5"
28
+ "gulp-util" : " ^3.0.5" ,
29
+ "yargs" : " ^3.10.0"
29
30
}
30
31
}
You can’t perform that action at this time.
0 commit comments