added support for "-" prefix in DEBUG

This commit is contained in:
Vinay Pulim 2012-02-07 14:14:03 -05:00
parent 119e661d79
commit e70fcc3863

View File

@ -27,11 +27,19 @@ exports.version = '0.5.0';
* Enabled debuggers.
*/
var names = (process.env.DEBUG || '')
var names = [],
skips = [];
(process.env.DEBUG || '')
.split(/[\s,]+/)
.map(function(name){
.forEach(function(name){
name = name.replace('*', '.*?');
return new RegExp('^' + name + '$');
if (name[0] === '-') {
skips.push(new RegExp('^' + name.substr(1) + '$'));
}
else {
names.push(new RegExp('^' + name + '$'));
}
});
/**
@ -97,7 +105,13 @@ function humanize(ms) {
*/
function debug(name) {
var match = names.some(function(re){
var match = skips.some(function(re){
return re.test(name);
});
if (match) return function(){};
match = names.some(function(re){
return re.test(name);
});