@lvce-editor/file-watcher-process 4.6.0 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1350,6 +1350,12 @@ const normalizeEvent2 = (id, eventName, path) => {
|
|
|
1350
1350
|
const errorCallback = error => {
|
|
1351
1351
|
console.error(`[file-watcher-process] ${error}`);
|
|
1352
1352
|
};
|
|
1353
|
+
const createIgnored = exclude => {
|
|
1354
|
+
const excludedNames = new Set(exclude);
|
|
1355
|
+
return path => {
|
|
1356
|
+
return path.split(/[\\/]/).some(part => excludedNames.has(part));
|
|
1357
|
+
};
|
|
1358
|
+
};
|
|
1353
1359
|
const watchFolders = async ({
|
|
1354
1360
|
exclude,
|
|
1355
1361
|
id,
|
|
@@ -1372,6 +1378,7 @@ const watchFolders = async ({
|
|
|
1372
1378
|
for (const root of roots) {
|
|
1373
1379
|
const path = fileURLToPath(root);
|
|
1374
1380
|
const watcher = new FSWatcher({
|
|
1381
|
+
ignored: createIgnored(exclude),
|
|
1375
1382
|
ignoreInitial: true,
|
|
1376
1383
|
ignorePermissionErrors: true
|
|
1377
1384
|
});
|
|
@@ -1397,6 +1404,15 @@ const watchFolders = async ({
|
|
|
1397
1404
|
} of watcherEntries) {
|
|
1398
1405
|
watcher.on('all', callback);
|
|
1399
1406
|
}
|
|
1407
|
+
const controller = new AbortController();
|
|
1408
|
+
controller.signal.addEventListener('abort', () => {
|
|
1409
|
+
void Promise.allSettled(watcherEntries.map(({
|
|
1410
|
+
watcher
|
|
1411
|
+
}) => watcher.close()));
|
|
1412
|
+
}, {
|
|
1413
|
+
once: true
|
|
1414
|
+
});
|
|
1415
|
+
add(id, controller);
|
|
1400
1416
|
const inotifyWatchCount = await getInotifyWatchCount();
|
|
1401
1417
|
if (inotifyWatchCount === undefined) {
|
|
1402
1418
|
return success;
|