Skip to content

Commit

Permalink
Merge pull request #72 from wouterbulten/master
Browse files Browse the repository at this point in the history
Favour built-in Mocha reporters over modules loaded by CasperJS.
  • Loading branch information
nathanboktae committed Dec 10, 2015
2 parents 7d57d2e + 2c98cf8 commit 7b17f50
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,25 @@ if (typeof process === 'undefined') {
// fall back to spec by default
var reporter = 'spec'

// Built-in Mocha reporters that are compatible
var mochaReporters = ['spec', 'xunit', 'json'];

if ( opts.reporter ) {
// check to see if it is a third party reporter
try {
// I don't want to use isAbsolute here as it could be a node module or a relative path
if (opts.reporter.indexOf('.') === 0) {
opts.reporter = fs.absolute(opts.reporter)
// Check for default and compatible Mocha reporters
if ( mochaReporters.indexOf(opts.reporter) !== -1) {
reporter = opts.reporter;
}
else {
// check to see if it is a third party reporter
try {
// I don't want to use isAbsolute here as it could be a node module or a relative path
if (opts.reporter.indexOf('.') === 0) {
opts.reporter = fs.absolute(opts.reporter)
}
reporter = require(opts.reporter)
} catch (e) {
reporter = opts.reporter
}
reporter = require(opts.reporter)
} catch (e) {
reporter = opts.reporter
}
}

Expand Down

0 comments on commit 7b17f50

Please sign in to comment.