Skip to content

Commit

Permalink
fix: Bug in building of paths
Browse files Browse the repository at this point in the history
Stopping modification of *global* variables `outputFile` and `outputDir`.

Closes #65
  • Loading branch information
budde377 authored and dignifiedquire committed Sep 29, 2015
1 parent 2e8f39e commit 1c36509
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for

var writeXmlForBrowser = function (browser) {
var safeBrowserName = browser.name.replace(/ /g, '_')
var newOutputFile
if (outputFile != null) {
outputDir = path.join(outputDir, safeBrowserName)
outputFile = path.join(outputDir, outputFile)
var dir = path.join(outputDir, safeBrowserName)
newOutputFile = path.join(dir, outputFile)
} else {
outputFile = path.join(outputDir, 'TESTS-' + safeBrowserName + '.xml')
newOutputFile = path.join(outputDir, 'TESTS-' + safeBrowserName + '.xml')
}

var xmlToOutput = suites[browser.id]
Expand All @@ -58,11 +59,11 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for

pendingFileWritings++
helper.mkdirIfNotExists(outputDir, function () {
fs.writeFile(outputFile, xmlToOutput.end({pretty: true}), function (err) {
fs.writeFile(newOutputFile, xmlToOutput.end({pretty: true}), function (err) {
if (err) {
log.warn('Cannot write JUnit xml\n\t' + err.message)
} else {
log.debug('JUnit results written to "%s".', outputFile)
log.debug('JUnit results written to "%s".', newOutputFile)
}

if (!--pendingFileWritings) {
Expand Down

0 comments on commit 1c36509

Please sign in to comment.