@@ -29,6 +29,7 @@ module.exports = function(gulp, config, pluginName){
29
29
tslintRules = require ( '../tslint.json' ) ;
30
30
31
31
var plugins = gulpLoadPlugins ( { } ) ;
32
+ var isWatch = false ;
32
33
33
34
/** Adjust the reference path of any typescript-built plugin this project depends on */
34
35
gulp . task ( 'path-adjust' , function ( ) {
@@ -48,6 +49,7 @@ module.exports = function(gulp, config, pluginName){
48
49
49
50
//gulp.task('tsc-' + pluginName, ['clean-defs'], function() {
50
51
gulp . task ( 'tsc-' + pluginName , function ( ) {
52
+ var wasError = false ;
51
53
var cwd = process . cwd ( ) ;
52
54
var tsResult = gulp . src ( config . ts ( pluginName ) )
53
55
. pipe ( plugins . sourcemaps . init ( ) )
@@ -56,12 +58,17 @@ module.exports = function(gulp, config, pluginName){
56
58
module : 'commonjs' ,
57
59
declarationFiles : true ,
58
60
noExternalResolve : false ,
59
- removeComments : true
60
- } ) ) )
61
- . on ( 'error' , plugins . notify . onError ( {
62
- message : 'Error: <%= error.message %>' ,
63
- title : 'Typescript compilation error'
64
- } ) ) ;
61
+ removeComments : true ,
62
+ noEmitOnError : false
63
+ } ) , { } , plugins . typescript . reporter . fullReporter ( true ) ) )
64
+ . on ( 'error' , function ( ) {
65
+ wasError = true ;
66
+ } )
67
+ . on ( 'end' , function ( ) {
68
+ if ( wasError && ! isWatch ) {
69
+ throw 'Error in one or more TypeScript files. The build is stopped.'
70
+ }
71
+ } ) ;
65
72
66
73
return eventStream . merge (
67
74
tsResult . js
@@ -86,7 +93,7 @@ module.exports = function(gulp, config, pluginName){
86
93
} ) ) ;
87
94
} ) ;
88
95
89
- gulp . task ( 'tslint-' + pluginName , function ( ) {
96
+ gulp . task ( 'tslint-' + pluginName , [ 'tsc-' + pluginName ] , function ( ) {
90
97
gulp . src ( config . ts ( pluginName ) )
91
98
. pipe ( tslint ( config . tsLintOptions ) )
92
99
. pipe ( tslint . report ( 'verbose' ) ) ;
@@ -139,6 +146,8 @@ module.exports = function(gulp, config, pluginName){
139
146
140
147
gulp . task ( 'watch-' + pluginName , [ 'build-' + pluginName ] , function ( ) {
141
148
149
+ isWatch = true ;
150
+
142
151
plugins . watch ( [ '.tmp/gulp-connect-server/index.html' , '.tmp/gulp-connect-server/dist/**' ] , function ( ) {
143
152
gulp . start ( [ 'reload' ] ) ;
144
153
} ) ;
@@ -210,5 +219,6 @@ module.exports = function(gulp, config, pluginName){
210
219
} ) ;
211
220
} ) ;
212
221
213
- gulp . task ( 'build-' + pluginName , [ 'path-adjust' , 'tslint-' + pluginName , 'tsc-' + pluginName , 'template-' + pluginName , 'less-' + pluginName , 'concat-' + pluginName , 'clean-' + pluginName ] ) ;
222
+ gulp . task ( 'build-' + pluginName , [ 'path-adjust' , 'tsc-' + pluginName , 'tslint-' + pluginName , 'template-' + pluginName ,
223
+ 'less-' + pluginName , 'concat-' + pluginName , 'clean-' + pluginName ] ) ;
214
224
} ;
0 commit comments