Skip to content

Commit

Permalink
Merge pull request #1677 from dariusj18/master
Browse files Browse the repository at this point in the history
feat: ability to disable debug message in ConditionalModule
  • Loading branch information
kamilmysliwiec authored Apr 5, 2024
2 parents ae7ec29 + ec6970f commit 8b37dfb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/conditional.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class ConditionalModule {
static async registerWhen(
module: Required<ModuleMetadata>['imports'][number],
condition: string | ((env: NodeJS.ProcessEnv) => boolean),
options?: { timeout: number },
options?: { timeout?: number; debug?: boolean },
) {
const { timeout = 5000 } = options ?? {};
const { timeout = 5000, debug = true } = options ?? {};

const timer = setTimeout(() => {
throw new Error(
Expand All @@ -38,10 +38,12 @@ export class ConditionalModule {
returnModule.imports.push(module);
returnModule.exports.push(module);
} else {
Logger.debug(
`${condition.toString()} evaluated to false. Skipping the registration of ${module.toString()}`,
ConditionalModule.name,
);
if (debug) {
Logger.debug(
`${condition.toString()} evaluated to false. Skipping the registration of ${module.toString()}`,
ConditionalModule.name,
);
}
}
return returnModule;
}
Expand Down

0 comments on commit 8b37dfb

Please sign in to comment.