jasmine-json-stream-reporter
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "jasmine-json-stream-reporter", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "jasmine json stream reporter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,4 +12,6 @@ 'use strict'; | ||
module.exports = function (reporter) { | ||
module.exports = function (reporters) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if (!Array.isArray(reporters)) reporters = [reporters]; | ||
var _options$onError = options.onError; | ||
@@ -20,5 +22,3 @@ var onError = _options$onError === undefined ? function (message) { | ||
var _options$onMessage = options.onMessage; | ||
var onMessage = _options$onMessage === undefined ? function (message) { | ||
return process.stdout.write(message); | ||
} : _options$onMessage; | ||
var onMessage = _options$onMessage === undefined ? function () {} : _options$onMessage; | ||
@@ -34,3 +34,5 @@ var failures = 0; | ||
if (reporter.print) return reporter.print(message); | ||
reporters.forEach(function (reporter) { | ||
return reporter.print && reporter.print(message); | ||
}); | ||
onMessage(message); | ||
@@ -41,14 +43,16 @@ } | ||
return through(function (chunk, enc, next) { | ||
for (var key in events) { | ||
if (events.hasOwnProperty(key)) { | ||
var value = events[key]; | ||
if (!chunk.id.endsWith(':' + key)) continue; | ||
if (typeof value === 'function') value(chunk); | ||
if (key in reporter) reporter[key](chunk); | ||
break; | ||
} | ||
} | ||
Object.keys(events).find(function (key) { | ||
var value = events[key]; | ||
if (!chunk.id.endsWith(':' + key)) return false; | ||
if (typeof value === 'function') value(chunk); | ||
reporters.forEach(function (reporter) { | ||
return key in reporter && reporter[key](chunk); | ||
}); | ||
return true; | ||
}); | ||
next(null, chunk); | ||
}, function (flush) { | ||
reporter.jasmineDone(); | ||
reporters.forEach(function (reporter) { | ||
return reporter.jasmineDone(); | ||
}); | ||
if (failures) handleFailures.call(this, failures, onError); | ||
@@ -55,0 +59,0 @@ flush(); |
11473
106