From 50468edd4c82dd16cc74312f71c0792c9420ef9d Mon Sep 17 00:00:00 2001 From: James Yang <26634873@qq.com> Date: Sun, 20 Jun 2021 11:17:21 +0800 Subject: [PATCH] feat: add mtime compare for path change I found it's better to compare `mtime` for stat and lastStat in `_enqueue`, if it's same, then skip. --- src/CheapWatch.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CheapWatch.ts b/src/CheapWatch.ts index a61f3fa..6a6efb2 100644 --- a/src/CheapWatch.ts +++ b/src/CheapWatch.ts @@ -126,6 +126,12 @@ export default class CheapWatch extends EventEmitter { continue; } const isNew = !this.paths.has(path); + if (!isNew) { + const lastStat = this.paths.get(path) + if (String(lastStat.mtime) === String(stats.mtime)) { + continue + } + } this.paths.set(path, stats); if (path) { this.emit('+', { path, stats, isNew });