Skip to content

Commit

Permalink
runner: allow to pass grep via options or env
Browse files Browse the repository at this point in the history
Fixes enb#61
Closes enbgh-62
  • Loading branch information
Alexej Yaroshevich committed Feb 16, 2015
1 parent 8bdd510 commit 4ccda54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ module.exports = function (helper) {
referenceDirSuffixes: options.referenceDirSuffixes || ['tmpl-specs'],
saveHtml: (typeof process.env.BEM_TMPL_SPECS_SAVE_HTML === 'undefined' ?
options.saveHtml :
process.env.BEM_TMPL_SPECS_SAVE_HTML) || false
process.env.BEM_TMPL_SPECS_SAVE_HTML) || false,
grep: (typeof process.env.BEM_TMPL_SPECS_GREP === 'undefined' ?
options.grep :
process.env.BEM_TMPL_SPECS_GREP) || false
};
},

Expand Down
16 changes: 15 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ exports.run = function (files, opts) {
var defer = vow.defer(),
mocha = new Mocha({
ui: 'bdd',
reporter: runReporters
reporter: runReporters,
grep: parseRe(opts.grep)
});

mocha.files = files;
Expand Down Expand Up @@ -96,3 +97,16 @@ function saveCoverageReport(coverage, opts) {
});
return defer.promise();
}

var regexpRe = /^\/(.+)\/(i?)$/;
function parseRe(str) {
if (typeof str !== 'string') {
return str;
}

var m = regexpRe.exec(str);
if (!m) {
return str;
}
return new RegExp(m[1], m[2]);
}

0 comments on commit 4ccda54

Please sign in to comment.