Skip to content

Commit d68c5cd

Browse files
committed
Merge pull request #74 from vrockai/HAWKULAR-47
HAWKULAR-47: Exit build on TypeScript errors
2 parents a7aeda4 + 9a60185 commit d68c5cd

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

build/gulpfile.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = function(gulp, config, pluginName){
2929
tslintRules = require('../tslint.json');
3030

3131
var plugins = gulpLoadPlugins({});
32+
var isWatch = false;
3233

3334
/** Adjust the reference path of any typescript-built plugin this project depends on */
3435
gulp.task('path-adjust', function() {
@@ -48,6 +49,7 @@ module.exports = function(gulp, config, pluginName){
4849

4950
//gulp.task('tsc-' + pluginName, ['clean-defs'], function() {
5051
gulp.task('tsc-' + pluginName, function() {
52+
var wasError = false;
5153
var cwd = process.cwd();
5254
var tsResult = gulp.src(config.ts(pluginName))
5355
.pipe(plugins.sourcemaps.init())
@@ -56,12 +58,17 @@ module.exports = function(gulp, config, pluginName){
5658
module: 'commonjs',
5759
declarationFiles: true,
5860
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+
});
6572

6673
return eventStream.merge(
6774
tsResult.js
@@ -86,7 +93,7 @@ module.exports = function(gulp, config, pluginName){
8693
}));
8794
});
8895

89-
gulp.task('tslint-' + pluginName, function(){
96+
gulp.task('tslint-' + pluginName, ['tsc-' + pluginName], function(){
9097
gulp.src(config.ts(pluginName))
9198
.pipe(tslint(config.tsLintOptions))
9299
.pipe(tslint.report('verbose'));
@@ -139,6 +146,8 @@ module.exports = function(gulp, config, pluginName){
139146

140147
gulp.task('watch-' + pluginName, ['build-' + pluginName], function() {
141148

149+
isWatch = true;
150+
142151
plugins.watch(['.tmp/gulp-connect-server/index.html', '.tmp/gulp-connect-server/dist/**'], function() {
143152
gulp.start(['reload']);
144153
});
@@ -210,5 +219,6 @@ module.exports = function(gulp, config, pluginName){
210219
});
211220
});
212221

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]);
214224
};

0 commit comments

Comments
 (0)