Skip to content

Commit e07e287

Browse files
author
Marc Rooding
committed
Updated the JSON output hook to handle missing report directory creation
1 parent 12e7345 commit e07e287

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# gulp-protractor-cucumber-html-report
22

3-
[![Build Status](https://travis-ci.org/mrooding/gulp-protractor-cucumber-html-report.svg?branch=master)](https://travis-ci.org/mrooding/gulp-protractor-cucumber-html-report)
4-
53
> Generate html report from JSON file returned by CucumberJS json formatter
64
75
This is a stand-alone fork of [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report)
@@ -62,9 +60,16 @@ module.exports = function JsonOutputHook() {
6260
var path = require('path');
6361

6462
JsonFormatter.log = function (json) {
65-
fs.writeFile(path.join(__dirname, './reports/cucumber-test-results.json'), json, function (err) {
66-
if (err) throw err;
67-
console.log('json file location: ' + path.join(__dirname, './reports/cucumber-test-results.json'));
63+
var destination = path.join(__dirname, '../../reports/cucumber-test-results.json');
64+
fs.open(destination, 'w+', function (err, fd) {
65+
if (err) {
66+
fs.mkdirsSync(destination);
67+
fd = fs.openSync(destination, 'w+');
68+
}
69+
70+
fs.writeSync(fd, json);
71+
72+
console.log('json file location: ' + destination);
6873
});
6974
};
7075

0 commit comments

Comments
 (0)