Skip to content

Commit 1f2abe5

Browse files
author
cloudhead
committed
(new) watch reporter
1 parent b9882a5 commit 1f2abe5

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

lib/vows/reporters/watch.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var sys = require('sys');
2+
3+
var options = {};
4+
var console = require('vows/console');
5+
var stylize = console.stylize,
6+
puts = console.puts(options);
7+
//
8+
// Console reporter
9+
//
10+
this.name = 'watch';
11+
this.report = function (data) {
12+
var event = data[1];
13+
14+
options.stream = process.stdout;
15+
16+
switch (data[0]) {
17+
case 'subject':
18+
puts(stylize(event, 'underline') + '\n');
19+
break;
20+
case 'vow':
21+
if (event.status !== 'honored') {
22+
if (event.status === 'broken') {
23+
puts(' - ' + stylize(event.title, 'yellow'));
24+
puts(' ~ ' + event.exception);
25+
puts('');
26+
} else if (event.status === 'errored') {
27+
puts(' - ' + stylize(event.title, 'red'));
28+
if (event.exception.type === 'promise') {
29+
puts(' * ' + stylize("An 'error' event was caught: " +
30+
stylize(event.exception.error, 'bold'), 'red'));
31+
} else {
32+
puts(' ! ' + stylize(event.exception, 'red'));
33+
}
34+
puts('');
35+
}
36+
}
37+
break;
38+
case 'error':
39+
puts('\n\n * ' + stylize(event.error, 'red'));
40+
break;
41+
}
42+
};
43+
this.print = function (str) {};

0 commit comments

Comments
 (0)