@jsenv/filesystem 4.10.10 → 4.10.12

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.10",
3
+ "version": "4.10.12",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  "/src/"
30
30
  ],
31
31
  "dependencies": {
32
- "@jsenv/urls": "2.5.2",
32
+ "@jsenv/urls": "2.5.3",
33
33
  "@jsenv/url-meta": "8.5.2",
34
34
  "@jsenv/abort": "4.3.0",
35
35
  "@jsenv/utils": "2.1.2"
@@ -1,8 +1,8 @@
1
1
  import { URL_META } from "@jsenv/url-meta";
2
2
  import { urlToFileSystemPath, urlToRelativeUrl } from "@jsenv/urls";
3
- import { readdirSync, statSync } from "node:fs";
4
-
3
+ import { readdirSync } from "node:fs";
5
4
  import { assertAndNormalizeDirectoryUrl } from "../path_and_url/directory_url_validation.js";
5
+ import { readEntryStatSync } from "../read_write/stat/read_entry_stat_sync.js";
6
6
  import { statsToType } from "../read_write/stat/stats_to_type.js";
7
7
  import { createWatcher } from "./create_watcher.js";
8
8
  import { guardTooFastSecondCallPerFile } from "./guard_second_call.js";
@@ -92,7 +92,7 @@ export const registerDirectoryLifecycle = (
92
92
  try {
93
93
  const relativeUrl = urlToRelativeUrl(url, source);
94
94
  const previousInfo = infoMap.get(relativeUrl);
95
- const stat = statSync(new URL(url));
95
+ const stat = readEntryStatSync(new URL(url));
96
96
  const type = statsToType(stat);
97
97
  const patternValue = previousInfo
98
98
  ? previousInfo.patternValue
@@ -169,7 +169,7 @@ export const registerDirectoryLifecycle = (
169
169
  const removedEntryRelativeUrl = relativeUrlCandidateArray.find(
170
170
  (relativeUrlCandidate) => {
171
171
  try {
172
- statSync(new URL(relativeUrlCandidate, sourceUrl));
172
+ readEntryStatSync(new URL(relativeUrlCandidate, sourceUrl));
173
173
  return false;
174
174
  } catch (e) {
175
175
  if (e.code === "ENOENT") {
@@ -250,7 +250,12 @@ export const registerDirectoryLifecycle = (
250
250
  const directoryUrlObject = new URL(directoryUrl);
251
251
  entryNameArray = readdirSync(directoryUrlObject);
252
252
  } catch (e) {
253
- if (e.code === "ENOENT" || e.code === "EACCES") {
253
+ if (
254
+ e.code === "ENOENT" ||
255
+ e.code === "EACCES" ||
256
+ e.code === "EPERM" ||
257
+ e.code === "ENOTDIR"
258
+ ) {
254
259
  return;
255
260
  }
256
261
  throw e;
@@ -282,7 +287,12 @@ export const registerDirectoryLifecycle = (
282
287
  });
283
288
  });
284
289
  } catch (e) {
285
- if (e.code === "ENOENT" || e.code === "EACCES") {
290
+ if (
291
+ e.code === "ENOENT" ||
292
+ e.code === "EACCES" ||
293
+ e.code === "EPERM" ||
294
+ e.code === "ENOTDIR"
295
+ ) {
286
296
  return;
287
297
  }
288
298
  throw e;
@@ -310,8 +320,8 @@ export const registerDirectoryLifecycle = (
310
320
  }
311
321
  };
312
322
  const handleEntryUpdated = (entryInfo) => {
313
- infoMap.set(entryInfo.relativeUrl, entryInfo);
314
323
  if (updated && entryInfo.patternValue && shouldCallUpdated(entryInfo)) {
324
+ infoMap.set(entryInfo.relativeUrl, entryInfo);
315
325
  updated({
316
326
  relativeUrl: entryInfo.relativeUrl,
317
327
  type: entryInfo.type,
@@ -1,8 +1,7 @@
1
1
  import { urlToFileSystemPath } from "@jsenv/urls";
2
- import { statSync } from "node:fs";
3
2
  import { basename, dirname } from "node:path";
4
-
5
3
  import { assertAndNormalizeFileUrl } from "../path_and_url/file_url_validation.js";
4
+ import { readEntryStatSync } from "../read_write/stat/read_entry_stat_sync.js";
6
5
  import { statsToType } from "../read_write/stat/stats_to_type.js";
7
6
  import { createWatcher } from "./create_watcher.js";
8
7
  import { guardTooFastSecondCall } from "./guard_second_call.js";
@@ -113,7 +112,7 @@ export const registerFileLifecycle = (
113
112
 
114
113
  const readFileInfo = (url) => {
115
114
  try {
116
- const stat = statSync(new URL(url));
115
+ const stat = readEntryStatSync(new URL(url));
117
116
  return {
118
117
  type: statsToType(stat),
119
118
  stat,
@@ -1,10 +1,9 @@
1
- import { statSync } from "node:fs";
2
-
1
+ import { readEntryStatSync } from "./read_entry_stat_sync.js";
3
2
  import { statsToType } from "./stats_to_type.js";
4
3
 
5
4
  export const readEntryInfo = (url) => {
6
5
  try {
7
- const stats = statSync(new URL(url));
6
+ const stats = readEntryStatSync(new URL(url));
8
7
  const type = statsToType(stats);
9
8
  return {
10
9
  type,
@@ -5,7 +5,6 @@
5
5
 
6
6
  import { urlToFileSystemPath } from "@jsenv/urls";
7
7
  import { lstatSync, statSync } from "node:fs";
8
-
9
8
  import { assertAndNormalizeFileUrl } from "../../path_and_url/file_url_validation.js";
10
9
  import { writeEntryPermissionsSync } from "./write_entry_permissions_sync.js";
11
10
 
@@ -1,6 +1,6 @@
1
1
  import { URL_META } from "@jsenv/url-meta";
2
- import { readdirSync, statSync } from "node:fs";
3
-
2
+ import { readdirSync } from "node:fs";
3
+ import { readEntryStatSync } from "../read_write/stat/read_entry_stat_sync.js";
4
4
  import { removeEntrySync } from "./remove_entry_sync.js";
5
5
 
6
6
  export const clearDirectorySync = (initialDirectoryUrl, pattern = "**/*") => {
@@ -40,7 +40,7 @@ export const clearDirectorySync = (initialDirectoryUrl, pattern = "**/*") => {
40
40
  const entryUrl = new URL(entryName, directoryUrl);
41
41
  let entryStat;
42
42
  try {
43
- entryStat = statSync(entryUrl);
43
+ entryStat = readEntryStatSync(entryUrl);
44
44
  } catch (e) {
45
45
  if (e && e.code === "ENOENT") {
46
46
  continue;