Skip to content

Commit a3b57c2

Browse files
committed
fix: debug flag and rewriting
1 parent c4bccf3 commit a3b57c2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

snippets/ai/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// tsc generates a module.exports for TypeScript files so we have this wrapper to load the module
1+
// tsc assigns to a global exports variable for TypeScript files which doesn't pair well
2+
// with mongosh scripts so we have this wrapper to load the module and minimize rewriting.
23
(() => {
34
const localRequire = require('module').createRequire(__filename);
45
// eslint-disable-next-line no-undef

snippets/ai/src/logger.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ const _localRequire = require('module').createRequire(__filename);
22
const localRequire = <T>(module: string): T => _localRequire(module);
33
const { EventEmitter } = localRequire<typeof import('events')>('events');
44

5-
const IS_DEBUG = process.env.DEBUG === 'true';
5+
const MONGOSH_AI_IS_DEBUG = process.env.DEBUG === 'true';
66

77
class Logger extends EventEmitter {
88
debug(...args: unknown[]) {
9-
if (IS_DEBUG) {
9+
if (MONGOSH_AI_IS_DEBUG) {
1010
// eslint-disable-next-line no-console
1111
console.debug(...args);
1212
this.emit('debug', ...args);
1313
}
1414
}
1515

1616
info(...args: unknown[]) {
17-
if (IS_DEBUG) {
17+
if (MONGOSH_AI_IS_DEBUG) {
1818
// eslint-disable-next-line no-console
1919
console.info(...args);
2020
this.emit('info', ...args);
2121
}
2222
}
2323

2424
error(...args: unknown[]) {
25-
if (IS_DEBUG) {
25+
if (MONGOSH_AI_IS_DEBUG) {
2626
// eslint-disable-next-line no-console
2727
console.error(...args);
2828
this.emit('error', ...args);

0 commit comments

Comments
 (0)