☕️ Classic, reliable, trusted test framework for Node.js and the browser
fix Mocha#grep(), escape regexp strings
TJ Holowaychukb00b6f54e0c3
diff --git a/bin/_mocha b/bin/_mochaindex bc3d944a..29f3accd 100755--- a/bin/_mocha+++ b/bin/_mocha@@ -218,7 +218,7 @@ mocha.suite.bail(program.bail);// --grep-if (program.grep) mocha.grep(new RegExp(utils.escapeRegexp(program.grep)));+if (program.grep) mocha.grep(new RegExp(program.grep));// --invertdiff --git a/lib/mocha.js b/lib/mocha.jsindex ef112d6e..70bcca27 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -8,7 +8,8 @@* Module dependencies.*/-var path = require('path');+var path = require('path')+ , utils = require('./utils');/*** Expose `Mocha`.@@ -20,7 +21,7 @@ exports = module.exports = Mocha;* Expose internals.*/-exports.utils = require('./utils');+exports.utils = utils;exports.interfaces = require('./interfaces');exports.reporters = require('./reporters');exports.Runnable = require('./runnable');@@ -154,16 +155,16 @@ Mocha.prototype._growl = function(runner, reporter) {};/**- * Add regexp to grep for to the options object+ * Add regexp to grep, if `re` is a string it is escaped.*- * @param {RegExp} or {String} re+ * @param {RegExp|String} re* @return {Mocha}* @api public*/Mocha.prototype.grep = function(re){this.options.grep = 'string' == typeof re- ? new RegExp(re)+ ? new RegExp(utils.escapeRegexp(re)): re;return this;};