| 18 | // Ensure debug directory exists for local environment |
| 19 | let debugDir: string | null | undefined |
| 20 | function getDebugDir(): string | null { |
| 21 | if (debugDir !== undefined) { |
| 22 | return debugDir |
| 23 | } |
| 24 | // Walk up from cwd to find the git root (where .git exists) |
| 25 | let dir = process.cwd() |
| 26 | while (dir !== path.dirname(dir)) { |
| 27 | if (fs.existsSync(path.join(dir, '.git'))) { |
| 28 | debugDir = path.join(dir, 'debug') |
| 29 | return debugDir |
| 30 | } |
| 31 | dir = path.dirname(dir) |
| 32 | } |
| 33 | debugDir = null |
| 34 | console.error('Failed to find git root directory for logger') |
| 35 | return debugDir |
| 36 | } |
| 37 | |
| 38 | // Initialize debug directory in dev environment |
| 39 | if (IS_DEV && !IS_CI) { |