@jsenv/filesystem 4.10.3 → 4.10.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/filesystem",
3
- "version": "4.10.3",
3
+ "version": "4.10.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -112,6 +112,12 @@ export const registerDirectoryLifecycle = (
112
112
  stat: null,
113
113
  };
114
114
  }
115
+ if (e.code === "EACCES") {
116
+ return {
117
+ type: null,
118
+ stat: null,
119
+ };
120
+ }
115
121
  throw e;
116
122
  }
117
123
  };
@@ -240,13 +246,24 @@ export const registerDirectoryLifecycle = (
240
246
  infoMap.set(entryInfo.relativeUrl, entryInfo);
241
247
  if (entryInfo.type === "directory") {
242
248
  const directoryUrl = `${entryInfo.url}/`;
243
- readdirSync(new URL(directoryUrl)).forEach((entryName) => {
249
+ let entryNameArray;
250
+ try {
251
+ const directoryUrlObject = new URL(directoryUrl);
252
+ entryNameArray = readdirSync(directoryUrlObject);
253
+ } catch (e) {
254
+ if (e.code === "ENOENT") {
255
+ entryNameArray = [];
256
+ } else {
257
+ throw e;
258
+ }
259
+ }
260
+ for (const entryName of entryNameArray) {
244
261
  const childEntryUrl = new URL(entryName, directoryUrl).href;
245
262
  const childEntryInfo = readEntryInfo(childEntryUrl);
246
263
  if (childEntryInfo.type !== null && childEntryInfo.patternValue) {
247
264
  handleEntryFound(childEntryInfo, { notify });
248
265
  }
249
- });
266
+ }
250
267
  // we must watch manually every directory we find
251
268
  if (!fsWatchSupportsRecursive) {
252
269
  const watcher = createWatcher(urlToFileSystemPath(entryInfo.url), {