From 0b1397c8d51efc8aaee0500c0d9a27c46a442511 Mon Sep 17 00:00:00 2001 From: Adam Gruber Date: Sun, 10 Apr 2016 17:58:46 -0400 Subject: [PATCH] fixes https://github.com/adamgruber/mochawesome/issues/40 --- .travis.yml | 5 ++++- changelog.md | 3 +++ gulpfile.js | 12 +++++++++--- lib/reportGenerator.js | 7 +++---- package.json | 4 +++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87f8cd9..d01fc04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ language: node_js node_js: - - "0.10" \ No newline at end of file + - "0.10" + - "0.12" + - "4" + - "5" \ No newline at end of file diff --git a/changelog.md b/changelog.md index c7f88b1..50a5cdf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ #Changelog +###1.3.3 +- Added support for creating custom dir where the parent dir(s) may not exist yet. See [#40](https://github.com/adamgruber/mochawesome/issues/40) + ###1.3.2 - Removed `allHooks` array since it was not being used and could lead to an issue where node runs out of memory while rendering the template. See [#33](https://github.com/adamgruber/mochawesome/issues/33) diff --git a/gulpfile.js b/gulpfile.js index 5620b7b..968c4a8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,7 +11,8 @@ var gulp = require('gulp'), wrap = require('gulp-wrap'), declare = require('gulp-declare'), watch = require('gulp-watch'), - mocha = require('gulp-spawn-mocha'), + mocha = require('gulp-mocha'), + spawnmocha = require('gulp-spawn-mocha'), config = require('./lib/config')(); var mochaOpts = { @@ -157,7 +158,7 @@ gulp.task('watch', function () { // Test Tasks gulp.task('fiveby', function () { return gulp.src(testPaths.fiveby) - .pipe(mocha(mochaOpts)) + .pipe(spawnmocha(mochaOpts)) .on('error', console.warn.bind(console)); }); @@ -181,7 +182,12 @@ gulp.task('test-recursive', function () { }); gulp.task('testOpts', function () { - mochaOpts.reporterOptions = 'reportDir=customDir,reportName=customName,reportTitle=customTitle,inlineAssets=true'; + mochaOpts.reporterOptions = { + reportDir: 'customDir', + reportName: 'customName', + reportTitle: 'customTitle', + inlineAssets: true + }; return gulp.src(testPaths.basic) .pipe(mocha(mochaOpts)) .on('error', console.warn.bind(console)); diff --git a/lib/reportGenerator.js b/lib/reportGenerator.js index 42811e2..ed59ab3 100644 --- a/lib/reportGenerator.js +++ b/lib/reportGenerator.js @@ -2,7 +2,8 @@ var async = require('async'), fs = require('fs'), ncp = require('ncp'), _ = require('lodash'), - chalk = require('chalk'); + chalk = require('chalk'), + mkdirp = require('mkdirp'); exports.generateReport = generateReport; exports.saveToFile = saveToFile; @@ -47,9 +48,7 @@ function createDirs (config, inline, callback) { dirs = dirs.concat([config.reportJsDir, config.reportFontsDir, config.reportCssDir]); } dirs.forEach(function(dir) { - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } + mkdirp.sync(dir); }); callback(null, 'done'); } diff --git a/package.json b/package.json index be55b4d..d36f0d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mochawesome", - "version": "1.3.2", + "version": "1.3.3", "description": "A Gorgeous HTML/CSS Reporter for Mocha.js", "scripts": { "test": "gulp build" @@ -26,6 +26,7 @@ "highlight.js": "^8.5.0", "json-stringify-safe": "^5.0.0", "lodash": "^3.1.0", + "mkdirp": "^0.5.1", "mocha": "*", "moment": "^2.9.0", "ncp": "^1.0.1", @@ -41,6 +42,7 @@ "gulp-handlebars": "^4.0.0", "gulp-jshint": "^1.9.0", "gulp-less": "^3.0.3", + "gulp-mocha": "^2.2.0", "gulp-plumber": "^0.6.6", "gulp-spawn-mocha": "^0.5.2", "gulp-uglify": "^1.1.0",