(dirPath: string, depth: number = 0)
| 159 | } |
| 160 | |
| 161 | private watchDirectory(dirPath: string, depth: number = 0): void { |
| 162 | if ( |
| 163 | depth > this.options.maxDepth || |
| 164 | this.shouldIgnorePath(dirPath) || |
| 165 | this.watchedDirs.has(dirPath) |
| 166 | ) { |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | try { |
| 171 | // Check if directory exists and is accessible |
| 172 | const stats = fs.statSync(dirPath); |
| 173 | if (!stats.isDirectory()) { |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | this.watchedDirs.add(dirPath); |
| 178 | this.setupWatcher(dirPath, depth); |
| 179 | this.watchSubdirectories(dirPath, depth); |
| 180 | } catch (error) { |
| 181 | console.error(`Failed to watch directory ${dirPath}:`, error); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | public startWatching(rootPath: string = process.cwd()): void { |
| 186 | this.stopWatching(); |
no test coverage detected