1 | |||
2 | var growl = require('./lib/growl') |
||
3 | |||
4 | growl('Support sound notifications', {title: 'Make a sound', sound: 'purr'}); |
||
5 | growl('You have mail!') |
||
6 | growl('5 new messages', { sticky: true }) |
||
7 | growl('5 new emails', { title: 'Email Client', image: 'Safari', sticky: true }) |
||
8 | growl('Message with title', { title: 'Title'}) |
||
9 | growl('Set priority', { priority: 2 }) |
||
10 | growl('Show Safari icon', { image: 'Safari' }) |
||
11 | growl('Show icon', { image: 'path/to/icon.icns' }) |
||
12 | growl('Show image', { image: 'path/to/my.image.png' }) |
||
13 | growl('Show png filesystem icon', { image: 'png' }) |
||
14 | growl('Show pdf filesystem icon', { image: 'article.pdf' }) |
||
15 | growl('Show pdf filesystem icon', { image: 'article.pdf' }, function(){ |
||
16 | console.log('callback'); |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
17 | }) |
||
18 | growl('Show pdf filesystem icon', { title: 'Use show()', image: 'article.pdf' }) |
||
19 | growl('here \' are \n some \\ characters that " need escaping', {}, function(error, stdout, stderr) { |
||
20 | if (error !== null) throw new Error('escaping failed:\n' + stdout + stderr); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
21 | }) |
||
22 | growl('Allow custom notifiers', { exec: 'echo XXX %s' }, function(error, stdout, stderr) { |
||
0 ignored issues
–
show
|
|||
23 | console.log(stdout); |
||
0 ignored issues
–
show
|
|||
24 | }) |
||
25 | growl('Allow custom notifiers', { title: 'test', exec: 'echo YYY' }, function(error, stdout, stderr) { |
||
0 ignored issues
–
show
|
|||
26 | console.log(stdout); |
||
0 ignored issues
–
show
|
|||
27 | }) |
||
28 | growl('Allow custom notifiers', { title: 'test', exec: 'echo ZZZ %s' }, function(error, stdout, stderr) { |
||
0 ignored issues
–
show
|
|||
29 | console.log(stdout); |
||
0 ignored issues
–
show
|
|||
30 | }) |
||
31 | growl('Open a URL', { url: 'https://npmjs.org/package/growl' }); |
||
32 |