Merge pull request #134 from jkuri/notifications

Automatic desktop notifications on build errors
This commit is contained in:
Filipe Silva 2016-01-24 02:19:09 +00:00
commit 0ac1629bee
4 changed files with 27 additions and 1 deletions

View File

@ -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-beta.0",
"es6-promise": "^3.0.2",

BIN
assets/angular.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -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;

View File

@ -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"
}
}