()
| 148 | } |
| 149 | |
| 150 | private startWatcher(): void { |
| 151 | const watcherConfig = { |
| 152 | ignored: [ |
| 153 | '**/node_modules/**', |
| 154 | '**/.git/**', |
| 155 | '**/dist/**', |
| 156 | '**/build/**', |
| 157 | '**/.DS_Store', |
| 158 | '**/*.log', |
| 159 | this.tempDir!, |
| 160 | ], |
| 161 | persistent: true, |
| 162 | ignoreInitial: true, |
| 163 | awaitWriteFinish: { |
| 164 | stabilityThreshold: 100, |
| 165 | pollInterval: 100, |
| 166 | }, |
| 167 | } |
| 168 | |
| 169 | this.watcher = chokidar.watch(this.options.watchPath, watcherConfig) |
| 170 | |
| 171 | this.watcher.on('add', (filePath) => this.handleChange('add', filePath)) |
| 172 | this.watcher.on('change', (filePath) => |
| 173 | this.handleChange('change', filePath), |
| 174 | ) |
| 175 | this.watcher.on('unlink', (filePath) => |
| 176 | this.handleChange('unlink', filePath), |
| 177 | ) |
| 178 | this.watcher.on('error', (error) => |
| 179 | this.log.error(`Watcher error: ${error.message}`), |
| 180 | ) |
| 181 | |
| 182 | this.watcher.on('ready', () => { |
| 183 | // Already shown in startup, no need to repeat |
| 184 | }) |
| 185 | } |
| 186 | |
| 187 | private handleChange(_type: ChangeEvent['type'], filePath: string): void { |
| 188 | const relativePath = path.relative(this.options.watchPath, filePath) |
no test coverage detected