Skip to content

Commit 2a3b579

Browse files
author
Marc Rooding
committed
Merge branch 'master' of github.com:mrooding/gulp-protractor-cucumber-html-report
2 parents 4eafa2b + 08d6453 commit 2a3b579

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,30 @@ function gulpProtractorCucumberHtmlReport(opts) {
2727

2828
return through.obj(function (file, enc, cb) {
2929
if (file.isNull()) {
30-
return cb(null, file);
30+
cb(null, file);
3131
}
3232

3333
if (file.isBuffer()) {
3434
var testResults = JSON.parse(file.contents);
3535

36-
fs.writeFileSync(opts.dest + '/' + opts.filename, formatter.generateReport(testResults, opts.templates));
36+
fs.open(opts.dest + '/' + opts.filename, 'w+', function (err, fd) {
37+
if (err) {
38+
fs.mkdirsSync(opts.dest);
39+
fd = fs.openSync(opts.dest + '/' + opts.filename, 'w+');
40+
}
41+
fs.writeSync(fd, formatter.generateReport(testResults, opts.templates));
42+
fs.copySync(currentDir + '/templates/assets', opts.dest + '/assets/');
3743

38-
fs.copySync(currentDir + '/templates/assets', opts.dest + '/assets/');
44+
gutil.log(PLUGIN_NAME + ':', 'File \'' + opts.filename + '\' has been created in \'' + opts.dest + '\' directory');
45+
46+
cb(null, file)
47+
});
3948

40-
gutil.log('File ' + opts.filename + ' has been created in \'' + opts.dest + '\' directory');
4149
} else {
4250
throw new PluginError(PLUGIN_NAME, '[Error] Currently only buffers are supported');
4351
}
44-
45-
return cb(null, file);
4652
});
4753
}
4854

4955
// Exporting the plugin main function
50-
module.exports = gulpProtractorCucumberHtmlReport;
56+
module.exports = gulpProtractorCucumberHtmlReport;

0 commit comments

Comments
 (0)