(level, ...args)
| 82 | |
| 83 | // Logging function with icons and colors |
| 84 | function log(level, ...args) { |
| 85 | const icons = { |
| 86 | debug: chalk.gray('•'), |
| 87 | info: chalk.blue('→'), |
| 88 | warn: chalk.yellow('!'), |
| 89 | error: chalk.red('✗'), |
| 90 | success: chalk.green('✓') |
| 91 | }; |
| 92 | |
| 93 | if (LOG_LEVELS[level] >= LOG_LEVEL) { |
| 94 | const icon = icons[level] || ''; |
| 95 | |
| 96 | // Only output to console if not in silent mode |
| 97 | if (!isSilentMode()) { |
| 98 | if (level === 'error') { |
| 99 | console.error(icon, chalk.red(...args)); |
| 100 | } else if (level === 'warn') { |
| 101 | console.warn(icon, chalk.yellow(...args)); |
| 102 | } else if (level === 'success') { |
| 103 | console.log(icon, chalk.green(...args)); |
| 104 | } else if (level === 'info') { |
| 105 | console.log(icon, chalk.blue(...args)); |
| 106 | } else { |
| 107 | console.log(icon, ...args); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | // Write to debug log if DEBUG=true |
| 113 | if (process.env.DEBUG === 'true') { |
| 114 | const logMessage = `[${level.toUpperCase()}] ${args.join(' ')}\n`; |
| 115 | fs.appendFileSync('init-debug.log', logMessage); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // Function to create directory if it doesn't exist |
| 120 | function ensureDirectoryExists(dirPath) { |
no test coverage detected