* Process changes. * * @param {string} dir * @param {string} event * @param {string} file * @public
(dir, event, file)
| 275 | */ |
| 276 | |
| 277 | processChange(dir, event, file) { |
| 278 | const fullPath = path.join(dir, file); |
| 279 | const relativePath = path.join(path.relative(this.root, dir), file); |
| 280 | |
| 281 | fs.lstat(fullPath, (error, stat) => { |
| 282 | if (error && error.code !== 'ENOENT') { |
| 283 | this.emit('error', error); |
| 284 | } else if (!error && stat.isDirectory()) { |
| 285 | // win32 emits usless change events on dirs. |
| 286 | if (event !== 'change') { |
| 287 | this.watchdir(fullPath); |
| 288 | if ( |
| 289 | common.isFileIncluded( |
| 290 | this.globs, |
| 291 | this.dot, |
| 292 | this.doIgnore, |
| 293 | relativePath, |
| 294 | ) |
| 295 | ) { |
| 296 | this.emitEvent(ADD_EVENT, relativePath, stat); |
| 297 | } |
| 298 | } |
| 299 | } else { |
| 300 | const registered = this.registered(fullPath); |
| 301 | if (error && error.code === 'ENOENT') { |
| 302 | this.unregister(fullPath); |
| 303 | this.stopWatching(fullPath); |
| 304 | this.unregisterDir(fullPath); |
| 305 | if (registered) { |
| 306 | this.emitEvent(DELETE_EVENT, relativePath); |
| 307 | } |
| 308 | } else if (registered) { |
| 309 | this.emitEvent(CHANGE_EVENT, relativePath, stat); |
| 310 | } else { |
| 311 | if (this.register(fullPath)) { |
| 312 | this.emitEvent(ADD_EVENT, relativePath, stat); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | }); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Triggers a 'change' event after debounding it to take care of duplicate |
no test coverage detected