1 | #!/usr/bin/env node
|
2 |
|
3 | 'use strict';
|
4 |
|
5 | var path = require('path');
|
6 | var growl = require('growl');
|
7 |
|
8 | process.stdin.pipe(process.stdout);
|
9 |
|
10 | function init() {
|
11 | process.stdin.pipe(require('tap-finished')(function (results) {
|
12 | var failed = results.fail.length + results.errors.length;
|
13 | var total = results.plan.end;
|
14 | notify(failed, total);
|
15 | init();
|
16 | }));
|
17 | }
|
18 |
|
19 | init();
|
20 |
|
21 | function image (name) {
|
22 | return path.join(__dirname, '../images/' , name + '.png');
|
23 | }
|
24 |
|
25 | function notify (failed, total) {
|
26 | var growlOptions = {
|
27 | name: 'tap',
|
28 | title: failed ? 'Failed' : 'Passed',
|
29 | image: image(failed ? 'error' : 'ok')
|
30 | };
|
31 |
|
32 | var message;
|
33 | if (failed) {
|
34 | message = failed + ' of ' + total + ' tests failed';
|
35 | } else {
|
36 | message = total + ' tests passed';
|
37 | }
|
38 |
|
39 | return growl(message, growlOptions);
|
40 | }
|