From 1c3650916318d4c2167ed86017dc9bf408020483 Mon Sep 17 00:00:00 2001 From: budde377 Date: Tue, 29 Sep 2015 08:39:14 +0200 Subject: [PATCH] fix: Bug in building of paths Stopping modification of *global* variables `outputFile` and `outputDir`. Closes #65 --- index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index acc5c45..3f272b9 100644 --- a/index.js +++ b/index.js @@ -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] @@ -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) {