From e70fcc38638f1699edeac4902a3667719d5cef20 Mon Sep 17 00:00:00 2001 From: Vinay Pulim Date: Tue, 7 Feb 2012 14:14:03 -0500 Subject: [PATCH] added support for "-" prefix in DEBUG --- lib/debug.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/debug.js b/lib/debug.js index 740ebb8..1be8b66 100644 --- a/lib/debug.js +++ b/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); });