karma-json-reporter
Advanced tools
Comparing version 1.0.1 to 1.1.0
24
index.js
/* jshint node: true */ | ||
'use strict'; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
// | ||
var JSONReporter = function (baseReporterDecorator) { | ||
var JSONReporter = function (baseReporterDecorator, config, helper) { | ||
baseReporterDecorator(this); | ||
@@ -15,2 +18,6 @@ | ||
var reporterConfig = config.jsonReporter || {}; | ||
var stdout = reporterConfig.stdout || true; | ||
var outputFile = (reporterConfig.outputFile) ? helper.normalizeWinPath(path.resolve(config.basePath, reporterConfig.outputFile )) : null; | ||
this.onSpecComplete = function(browser, result) { | ||
@@ -25,3 +32,14 @@ history.result[browser.id] = history.result[browser.id] || []; | ||
history.summary = result; | ||
process.stdout.write(JSON.stringify(history)); | ||
if(stdout) process.stdout.write(JSON.stringify(history)); | ||
if(outputFile) { | ||
helper.mkdirIfNotExists(path.dirname(outputFile), function() { | ||
fs.writeFile(outputFile, JSON.stringify(history), function(err) { | ||
if (err) { | ||
log.warn('Cannot write JSON\n\t' + err.message); | ||
} else { | ||
log.debug('JSON written to "%s".', outputFile); | ||
} | ||
}); | ||
}); | ||
} | ||
history.result = {}; | ||
@@ -31,3 +49,3 @@ }; | ||
JSONReporter.$inject = ['baseReporterDecorator']; | ||
JSONReporter.$inject = ['baseReporterDecorator','config','helper']; | ||
@@ -34,0 +52,0 @@ // PUBLISH DI MODULE |
{ | ||
"name": "karma-json-reporter", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "JSON reporter for Karma", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,3 +14,3 @@ # karma-json-reporter [![NPM version](https://badge.fury.io/js/karma-json-reporter.png)](http://badge.fury.io/js/karma-json-reporter) | ||
"karma": "~0.10", | ||
"karma-json-reporter": "~1.0" | ||
"karma-json-reporter": "~1.1" | ||
} | ||
@@ -36,2 +36,6 @@ } | ||
reporters: ['json'], | ||
jsonReporter: { | ||
stdout: true, | ||
outputFile: 'results.json' // defaults to none | ||
} | ||
@@ -38,0 +42,0 @@ // ... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5020
42
92
1