Skip to content

Commit

Permalink
Merge pull request #46 from adamgruber/develop
Browse files Browse the repository at this point in the history
1.3.4
  • Loading branch information
adamgruber committed Apr 18, 2016
2 parents 2da7f7a + fd3ffa7 commit 7f56543
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#Changelog

###1.3.4
- Added option to auto open report. Also fixed an issue with boolean options. See [#44](https://github.com/adamgruber/mochawesome/issues/44)

###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)

Expand Down
10 changes: 9 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,21 @@ gulp.task('testOpts', function () {
reportDir: 'customDir',
reportName: 'customName',
reportTitle: 'customTitle',
inlineAssets: true
inlineAssets: true,
autoOpen: true
};
return gulp.src(testPaths.basic)
.pipe(mocha(mochaOpts))
.on('error', console.warn.bind(console));
});

gulp.task('testOpts2', function () {
mochaOpts.reporterOptions = 'reportDir=customDir,reportName=customName,reportTitle=customTitle,inlineAssets=true,autoOpen=true';
return gulp.src(testPaths.basic)
.pipe(spawnmocha(mochaOpts))
.on('error', console.warn.bind(console));
});

// Default/Combo Tasks
gulp.task('build', ['lint'], function () {
return gulp.start('assemble');
Expand Down
13 changes: 10 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (options) {
config.reportDir = _getOption('reportDir', options);
config.reportTitle = _getOption('reportTitle', options);
config.inlineAssets = _getOption('inlineAssets', options, true);
config.autoOpen = _getOption('autoOpen', options, true);
config.nodeModulesDir = path.join(__dirname, '..', 'node_modules');

// Build Directories
Expand Down Expand Up @@ -61,10 +62,16 @@ function _getOption (optToGet, options, isBool) {
// 2. Environment variable
// 3. Base config
if (options && typeof options[optToGet] !== 'undefined') {
return isBool ? options[optToGet] === 'true' : options[optToGet];
return (isBool && typeof options[optToGet] === 'string') ?
options[optToGet] === 'true'
: options[optToGet];
}
if (typeof process.env[envVar] !== 'undefined') {
return isBool ? process.env[envVar] === 'true' : process.env[envVar];
return (isBool && typeof options[optToGet] === 'string') ?
process.env[envVar] === 'true'
: process.env[envVar];
}
return isBool ? config[optToGet] === 'true' : config[optToGet];
return (isBool && typeof config[optToGet] === 'string') ?
config[optToGet] === 'true'
: config[optToGet];
}
6 changes: 5 additions & 1 deletion lib/mochawesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var mocha = require('mocha'),
reportGen = require('./reportGenerator'),
stringify = require('json-stringify-safe'),
conf = require('./config'),
templates = require('./templates.js');
templates = require('./templates.js'),
opener = require('opener');

var Base = mocha.reporters.Base,
generateReport = reportGen.generateReport,
Expand Down Expand Up @@ -110,6 +111,9 @@ function Mochawesome (runner, options) {
saveToFile(stringify(obj, null, 2), config.reportJsonFile, function(){});
saveToFile(templates.mochawesome(obj), config.reportHtmlFile, function() {
console.log('\n[' + chalk.gray('mochawesome') + '] Report saved to ' + config.reportHtmlFile + '\n\n');
if (config.autoOpen) {
opener(config.reportHtmlFile);
}
});
}
} catch (e) { //required because thrown errors are not handled directly in the event emitter pattern and mocha does not have an "on error"
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mochawesome",
"version": "1.3.3",
"version": "1.3.4",
"description": "A Gorgeous HTML/CSS Reporter for Mocha.js",
"scripts": {
"test": "gulp build"
Expand Down Expand Up @@ -30,7 +30,8 @@
"mocha": "*",
"moment": "^2.9.0",
"ncp": "^1.0.1",
"node-uuid": "^1.4.1"
"node-uuid": "^1.4.1",
"opener": "^1.4.1"
},
"devDependencies": {
"bootstrap": "^3.3.2",
Expand Down

0 comments on commit 7f56543

Please sign in to comment.