(
eventType: fs.WatchEventType,
dirPath: string,
name: string,
)
| 201 | } |
| 202 | |
| 203 | function handleFileEvent( |
| 204 | eventType: fs.WatchEventType, |
| 205 | dirPath: string, |
| 206 | name: string, |
| 207 | ): void { |
| 208 | const filePath = path.join(dirPath, name); |
| 209 | |
| 210 | if (fileSystem.isIgnored(filePath, watchRoot)) { |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | const stats = getPathStats(filePath); |
| 215 | if (stats === undefined) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | if (stats === null) { |
| 220 | handleDeletion(filePath); |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | if (stats.isDirectory()) { |
| 225 | watchDirectory(filePath); |
| 226 | return; |
| 227 | } |
| 228 | |
| 229 | if (!stats.isFile()) { |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | void uploadFile( |
| 234 | store, |
| 235 | options.store, |
| 236 | filePath, |
| 237 | path.basename(filePath), |
| 238 | config, |
| 239 | ) |
| 240 | .then((didUpload) => { |
| 241 | if (didUpload) { |
| 242 | console.log(`${eventType}: ${filePath}`); |
| 243 | } |
| 244 | }) |
| 245 | .catch((error) => { |
| 246 | console.error("Failed to upload changed file:", filePath, error); |
| 247 | }); |
| 248 | } |
| 249 | |
| 250 | function watchDirectory(dirPath: string): void { |
| 251 | if (watchers.has(dirPath)) { |
no test coverage detected