()
| 118 | } |
| 119 | |
| 120 | get watcher() { |
| 121 | if(this.#watcher) { |
| 122 | return this.#watcher; |
| 123 | } |
| 124 | |
| 125 | debug("Watching %O", this.options.watch); |
| 126 | // TODO if using Eleventy and `watch` option includes output folder (_site) this will trigger two update events! |
| 127 | this.#watcher = chokidar.watch(this.options.watch, { |
| 128 | // TODO allow chokidar configuration extensions (or re-use the ones in Eleventy) |
| 129 | |
| 130 | ignored: ["**/node_modules/**", ".git"], |
| 131 | ignoreInitial: true, |
| 132 | |
| 133 | // same values as Eleventy |
| 134 | awaitWriteFinish: { |
| 135 | stabilityThreshold: 150, |
| 136 | pollInterval: 25, |
| 137 | }, |
| 138 | }); |
| 139 | |
| 140 | this.#watcher.on("change", (path) => { |
| 141 | this.logger.log( `File changed: ${path} (skips build)` ); |
| 142 | this.reloadFiles([path]); |
| 143 | }); |
| 144 | |
| 145 | this.#watcher.on("add", (path) => { |
| 146 | this.logger.log( `File added: ${path} (skips build)` ); |
| 147 | this.reloadFiles([path]); |
| 148 | }); |
| 149 | |
| 150 | return this.#watcher; |
| 151 | } |
| 152 | |
| 153 | getWatcher() { |
| 154 | // only initialize watcher if watcher via getWatcher if has targets |
nothing calls this directly
no test coverage detected