diff --git a/bin/_mocha b/bin/_mocha index 6f118e44b5..f7e8d18892 100755 --- a/bin/_mocha +++ b/bin/_mocha @@ -171,9 +171,10 @@ program.on('require', function(mod){ requires.push(mod); }); -// load mocha.opts into process.argv - -getOptions(); +// If not already done, load mocha.opts +if (!process.env.LOADED_MOCHA_OPTS) { + getOptions(); +} // parse args diff --git a/bin/mocha b/bin/mocha index b35e87c8d2..7e53e51d65 100755 --- a/bin/mocha +++ b/bin/mocha @@ -8,8 +8,13 @@ var spawn = require('child_process').spawn, path = require('path'), fs = require('fs'), + getOptions = require('./options'), args = [path.join(__dirname, '_mocha')]; +// Load mocha.opts into process.argv +// Must be loaded here to handle node-specific options +getOptions(); + process.argv.slice(2).forEach(function(arg){ var flag = arg.split('=')[0]; diff --git a/bin/options.js b/bin/options.js index 6e12d51672..9d1a18a23e 100644 --- a/bin/options.js +++ b/bin/options.js @@ -34,4 +34,6 @@ function getOptions() { } catch (err) { // ignore } + + process.env.LOADED_MOCHA_OPTS = true; }