forked from laravel/elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notification.js
80 lines (71 loc) · 1.65 KB
/
Notification.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var notify = require('gulp-notify');
/**
* Create a new Notification instance.
*/
var Notification = function() {
this.title = 'Laravel Elixir';
// If an argument is provided, then we'll
// assume they want to show a message.
if (arguments.length) {
return this.message(arguments[0]);
}
};
var n = Notification.prototype;
/**
* Display a notification.
*
* @param {string} message
*/
n.message = function(message) {
return notify({
title: this.title,
message: message,
icon: __dirname + '/icons/laravel.png',
onLast: true
});
};
/**
* Display an error notification.
*
* @param {object} e
* @param {string} message
*/
n.error = function(e, message) {
notify.onError({
title: this.title,
message: message + ': <%= error.message %>',
icon: __dirname + '/icons/fail.png',
onLast: true
})(e);
// We'll spit out the error, just in
// case it is useful for the user.
console.log(e);
};
/**
* Display a notification for passed tests.
*
* @param {string} framework
*/
n.forPassedTests = function(framework) {
return notify({
title: 'Green!',
message: 'Your ' + framework + ' tests passed!',
icon: __dirname + '/icons/pass.png',
onLast: true
});
};
/**
* Display a notification for failed tests.
*
* @param {object} e
* @param {string} framework
*/
n.forFailedTests = function(e, framework) {
return notify.onError({
title: 'Red!',
message: 'Your ' + framework + ' tests failed!',
icon: __dirname + '/icons/fail.png',
onLast: true
})(e);
};
module.exports = Notification;