Skip to content

Commit

Permalink
fix(resolveConfig): let debug mode be enabled through package.json again
Browse files Browse the repository at this point in the history
fixes #834
  • Loading branch information
hasezoey committed Dec 12, 2023
1 parent 44ade25 commit 8ba83c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/mongodb-memory-server-core/src/util/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,25 @@ export function envToBool(env: string = ''): boolean {
return ['1', 'on', 'yes', 'true'].indexOf(env.toLowerCase()) !== -1;
}

/**
* This exists because "debug.enabled('MongoMS:*')" will always return "true"
* This is used to not double-enable / double-print the enablement message
*/
let debug_enabled = false;

// enable debug if "MONGOMS_DEBUG" is true
if (envToBool(resolveConfig(ResolveConfigVariables.DEBUG))) {
debug.enable('MongoMS:*');
log('Debug Mode Enabled, through Environment Variable');
debug_enabled = true;
}

// run this after env debug enable to be able to debug this function too
findPackageJson();

// enable debug if "config.mongodbMemoryServer.debug" is true
if (envToBool(resolveConfig(ResolveConfigVariables.DEBUG)) && !debug.enabled('MongoMS:*')) {
if (envToBool(resolveConfig(ResolveConfigVariables.DEBUG)) && !debug_enabled) {
debug.enable('MongoMS:*');
log('Debug Mode Enabled, through package.json');
debug_enabled = true;
}

0 comments on commit 8ba83c7

Please sign in to comment.