@type {WatchMethod}
(files, dirs, missing, startTime, options, callback, callbackUndelayed)
| 30 | |
| 31 | /** @type {WatchMethod} */ |
| 32 | watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) { |
| 33 | files = [...files]; |
| 34 | dirs = [...dirs]; |
| 35 | /** |
| 36 | * Returns true, if path is ignored. |
| 37 | * @param {string} path path to check |
| 38 | * @returns {boolean} true, if path is ignored |
| 39 | */ |
| 40 | const ignored = (path) => |
| 41 | this.paths.some((p) => |
| 42 | p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0 |
| 43 | ); |
| 44 | |
| 45 | const [ignoredFiles, notIgnoredFiles] = groupBy( |
| 46 | /** @type {string[]} */ |
| 47 | (files), |
| 48 | ignored |
| 49 | ); |
| 50 | const [ignoredDirs, notIgnoredDirs] = groupBy( |
| 51 | /** @type {string[]} */ |
| 52 | (dirs), |
| 53 | ignored |
| 54 | ); |
| 55 | |
| 56 | const watcher = this.wfs.watch( |
| 57 | notIgnoredFiles, |
| 58 | notIgnoredDirs, |
| 59 | missing, |
| 60 | startTime, |
| 61 | options, |
| 62 | (err, fileTimestamps, dirTimestamps, changedFiles, removedFiles) => { |
| 63 | if (err) return callback(err); |
| 64 | for (const path of ignoredFiles) { |
| 65 | /** @type {TimeInfoEntries} */ |
| 66 | (fileTimestamps).set(path, IGNORE_TIME_ENTRY); |
| 67 | } |
| 68 | |
| 69 | for (const path of ignoredDirs) { |
| 70 | /** @type {TimeInfoEntries} */ |
| 71 | (dirTimestamps).set(path, IGNORE_TIME_ENTRY); |
| 72 | } |
| 73 | |
| 74 | callback( |
| 75 | null, |
| 76 | fileTimestamps, |
| 77 | dirTimestamps, |
| 78 | changedFiles, |
| 79 | removedFiles |
| 80 | ); |
| 81 | }, |
| 82 | callbackUndelayed |
| 83 | ); |
| 84 | |
| 85 | return { |
| 86 | close: () => watcher.close(), |
| 87 | pause: () => watcher.pause(), |
| 88 | getContextTimeInfoEntries: () => { |
| 89 | const dirTimestamps = watcher.getContextTimeInfoEntries(); |