UNPKG

895 BJavaScriptView Raw
1#!/usr/bin/env node
2
3'use strict';
4
5var path = require('path');
6var growl = require('growl');
7
8process.stdin.pipe(process.stdout);
9
10function 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(); // keep watching for next test run
16 }));
17}
18
19init();
20
21function image (name) {
22 return path.join(__dirname, '../images/' , name + '.png');
23}
24
25function 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}