mirror of
https://github.com/debug-js/debug.git
synced 2026-01-25 16:42:28 +00:00
added support for "-" prefix in DEBUG
This commit is contained in:
parent
119e661d79
commit
e70fcc3863
22
lib/debug.js
22
lib/debug.js
@ -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);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user