diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index 0555c2d9a7b2..be609c027cdc 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -2,6 +2,12 @@ "name": "<%= htmlComponentName %>", "version": "0.0.0", "license": "Apache-2.0", + "angular-cli": { + "notifications": { + "enabled": true, + "playSound": false + } + }, "dependencies": { "angular2": "2.0.0-alpha.55", "es6-promise": "^3.0.2", diff --git a/assets/angular.png b/assets/angular.png new file mode 100644 index 000000000000..7929242740ed Binary files /dev/null and b/assets/angular.png differ diff --git a/lib/broccoli/broccoli-typescript.js b/lib/broccoli/broccoli-typescript.js index dab2d6dc0958..fdd45adadb1f 100644 --- a/lib/broccoli/broccoli-typescript.js +++ b/lib/broccoli/broccoli-typescript.js @@ -4,6 +4,7 @@ var fse = require('fs-extra'); var path = require('path'); var ts = require('typescript'); var diffing_broccoli_plugin_1 = require('./diffing-broccoli-plugin'); +var notifier = require('node-notifier'); var FS_OPTS = { encoding: 'utf-8' }; @@ -44,6 +45,7 @@ var DiffingTSCompiler = (function () { this.tsOpts.outDir = this.cachePath; this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths, this.fileRegistry, this.inputPath); this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry()); + this.config = require(path.resolve(this.cachePath, '..', '..', 'package.json')); } DiffingTSCompiler.prototype.rebuild = function (treeDiff) { var _this = this; @@ -93,6 +95,7 @@ var DiffingTSCompiler = (function () { this.previousRunFailed = true; var error = new Error('Typescript found the following errors:\n' + errorMessages.join('\n')); error['showStack'] = false; + this.showNotification(errorMessages); throw error; } else if (this.previousRunFailed) { @@ -142,6 +145,7 @@ var DiffingTSCompiler = (function () { this.previousRunFailed = true; var error = new Error('Typescript found the following errors:\n' + errorMessages.join('\n')); error['showStack'] = false; + this.showNotification(errorMessages); throw error; } else { @@ -186,6 +190,21 @@ var DiffingTSCompiler = (function () { fs.unlinkSync(absoluteDtsFilePath); } }; + + DiffingTSCompiler.prototype.showNotification = function (errorMessages) { + if (!this.config['angular-cli'].notifications.enabled) { + return; + } + + notifier.notify({ + title: 'Build Errors: ' + errorMessages.length, + message: errorMessages.map(function (msg) { return msg.trim(); }).join('\n'), + icon: path.resolve(__dirname, '..', '..', 'assets', 'angular.png'), + sound: this.config['angular-cli'].notifications.playSound, + wait: false + }); + }; + DiffingTSCompiler.includeExtensions = ['.ts']; DiffingTSCompiler.excludeExtensions = ['.d.ts']; return DiffingTSCompiler; diff --git a/package.json b/package.json index acbea66439ed..b92637d6d86e 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "fs-extra": "^0.18.4", "leek": "0.0.19", "lodash": "^3.10.0", + "node-notifier": "^4.4.0", "resolve": "^1.0.0", "silent-error": "^1.0.0", "symlink-or-copy": "^1.0.1", @@ -59,6 +60,6 @@ "mocha": "^2.2.5", "rewire": "^2.3.4", "through": "^2.3.8", - "walk-sync": "^0.1.3" + "walk-sync": "^0.2.6" } }