MCPcopy
hub / github.com/jestjs/jest / processChange

Method processChange

packages/jest-haste-map/src/watchers/NodeWatcher.js:277–317  ·  view source on GitHub ↗

* Process changes. * * @param {string} dir * @param {string} event * @param {string} file * @public

(dir, event, file)

Source from the content-addressed store, hash-verified

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

Callers 1

normalizeChangeMethod · 0.95

Calls 9

watchdirMethod · 0.95
emitEventMethod · 0.95
registeredMethod · 0.95
unregisterMethod · 0.95
stopWatchingMethod · 0.95
unregisterDirMethod · 0.95
registerMethod · 0.95
isFileIncludedMethod · 0.80
emitMethod · 0.45

Tested by

no test coverage detected