Skip to content

fix: merge namespaces in enable() instead of flushing them - #1050

Open
arronKler wants to merge 1 commit into
debug-js:masterfrom
arronKler:fix/425-enable-no-flush
Open

fix: merge namespaces in enable() instead of flushing them#1050
arronKler wants to merge 1 commit into
debug-js:masterfrom
arronKler:fix/425-enable-no-flush

Conversation

@arronKler

Copy link
Copy Markdown

debug.enable() currently clears names/skips before applying the new list. That means previously enabled namespaces (including those from DEBUG) disappear:

DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
// false

This also breaks independent enable() calls from different modules that share one debug install.

Solution: treat enable() as additive. Incoming namespaces are merged with the existing set (skip tokens still disable a matching name; enabling a name again removes its skip). disable() still clears everything and is the way to replace:

debug.disable();
debug.enable('bar');

Fixes #425

enable() currently wipes names/skips, so DEBUG=foo followed by
enable("bar") disables foo. Merge incoming namespaces with the
existing set. Call disable() first when replacement is intended.

Fixes debug-js#425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

debug.enable() flushes enabled namespaces

1 participant