@jsenv/filesystem 4.10.4 → 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.4",
3
+ "version": "4.10.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -246,13 +246,24 @@ export const registerDirectoryLifecycle = (
246
246
  infoMap.set(entryInfo.relativeUrl, entryInfo);
247
247
  if (entryInfo.type === "directory") {
248
248
  const directoryUrl = `${entryInfo.url}/`;
249
- 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) {
250
261
  const childEntryUrl = new URL(entryName, directoryUrl).href;
251
262
  const childEntryInfo = readEntryInfo(childEntryUrl);
252
263
  if (childEntryInfo.type !== null && childEntryInfo.patternValue) {
253
264
  handleEntryFound(childEntryInfo, { notify });
254
265
  }
255
- });
266
+ }
256
267
  // we must watch manually every directory we find
257
268
  if (!fsWatchSupportsRecursive) {
258
269
  const watcher = createWatcher(urlToFileSystemPath(entryInfo.url), {