diff options
author | Joao Moreno <jomo@microsoft.com> | 2016-02-23 11:33:16 +0300 |
---|---|---|
committer | Joao Moreno <jomo@microsoft.com> | 2016-02-23 11:33:16 +0300 |
commit | c6ae31a9ae071abd31e2f25060f7aa22a293959f (patch) | |
tree | 227b97358153138b027957de747a9fca27859068 | |
parent | 89b641e2696e8950a3f71555a1dab36618fbbb8d (diff) |
make build fail on compile errors
-rw-r--r-- | build/gulpfile.plugins.js | 2 | ||||
-rw-r--r-- | build/lib/reporter.js | 20 | ||||
-rw-r--r-- | gulpfile.js | 6 |
3 files changed, 17 insertions, 11 deletions
diff --git a/build/gulpfile.plugins.js b/build/gulpfile.plugins.js index 51f0b50c6fa..efbf493216a 100644 --- a/build/gulpfile.plugins.js +++ b/build/gulpfile.plugins.js @@ -114,7 +114,7 @@ var tasks = readAllPlugins() .pipe(tsFilter) .pipe(compilation()) .pipe(tsFilter.restore) - .pipe(quiet ? es.through() : reporter()); + .pipe(quiet ? es.through() : reporter.end()); return es.duplex(input, output); }; diff --git a/build/lib/reporter.js b/build/lib/reporter.js index e3e61b9da91..84c1e9d4805 100644 --- a/build/lib/reporter.js +++ b/build/lib/reporter.js @@ -18,7 +18,7 @@ function onEnd() { } var errors = _.flatten(allErrors); - errors.map(function (err) { console.log('*** Error:', err); }); + errors.map(function (err) { console.error('*** Error:', err); }); console.log('*** Finished with', errors.length, 'errors.'); } @@ -26,17 +26,23 @@ module.exports = function () { var errors = []; allErrors.push(errors); - return function (err) { - if (err) { - errors.push(err); - return; - } + var result = function (err) { + errors.push(err); + }; + result.end = function (emitError) { errors.length = 0; onStart(); return es.through(null, function () { onEnd(); - this.emit('end'); + + if (emitError && errors.length > 0) { + this.emit('error', 'Errors occurred.'); + } else { + this.emit('end'); + } }); }; + + return result; };
\ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 28159b34305..81ed06e4de1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,7 +39,7 @@ var tsOptions = { sourceRoot: util.toFileUri(rootDir) }; -function createCompile(build) { +function createCompile(build, emitError) { var opts = _.clone(tsOptions); opts.inlineSources = !!build; @@ -67,14 +67,14 @@ function createCompile(build) { sourceRoot: tsOptions.sourceRoot })) .pipe(tsFilter.restore) - .pipe(quiet ? es.through() : reporter()); + .pipe(quiet ? es.through() : reporter.end(emitError)); return es.duplex(input, output); }; } function compileTask(out, build) { - var compile = createCompile(build); + var compile = createCompile(build, true); return function () { var src = gulp.src('src/**', { base: 'src' }); |