@jsenv/filesystem 4.13.3 → 4.13.4
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 +1 -1
- package/src/lifecycle/create_watcher.js +5 -1
- package/src/read_write/stat/read_entry_stat.js +5 -1
- package/src/read_write/stat/read_entry_stat_sync.js +5 -1
- package/src/remove/remove_entry.js +5 -2
- package/src/remove/remove_entry_sync.js +5 -1
- package/src/window_eperm_error.js +20 -0
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { closeSync, openSync, watch } from "node:fs";
|
|
2
|
+
import { generateWindowsEPERMErrorMessage } from "../window_eperm_error.js";
|
|
2
3
|
|
|
3
4
|
const isWindows = process.platform === "win32";
|
|
4
5
|
|
|
@@ -17,7 +18,10 @@ export const createWatcher = (sourcePath, options) => {
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
console.error(
|
|
20
|
-
|
|
21
|
+
generateWindowsEPERMErrorMessage(error, {
|
|
22
|
+
operation: "watch",
|
|
23
|
+
path: sourcePath,
|
|
24
|
+
}),
|
|
21
25
|
);
|
|
22
26
|
throw error;
|
|
23
27
|
}
|
|
@@ -7,6 +7,7 @@ import { urlToFileSystemPath } from "@jsenv/urls";
|
|
|
7
7
|
import { lstat, stat } from "node:fs";
|
|
8
8
|
|
|
9
9
|
import { assertAndNormalizeFileUrl } from "../../path_and_url/file_url_validation.js";
|
|
10
|
+
import { generateWindowsEPERMErrorMessage } from "../../window_eperm_error.js";
|
|
10
11
|
import { writeEntryPermissions } from "./write_entry_permissions.js";
|
|
11
12
|
|
|
12
13
|
const isWindows = process.platform === "win32";
|
|
@@ -54,7 +55,10 @@ export const readEntryStat = async (
|
|
|
54
55
|
return stats;
|
|
55
56
|
} catch (e) {
|
|
56
57
|
console.error(
|
|
57
|
-
|
|
58
|
+
generateWindowsEPERMErrorMessage(e, {
|
|
59
|
+
operation: "stats",
|
|
60
|
+
path: sourcePath,
|
|
61
|
+
}),
|
|
58
62
|
);
|
|
59
63
|
throw error;
|
|
60
64
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { urlToFileSystemPath } from "@jsenv/urls";
|
|
7
7
|
import { lstatSync, statSync } from "node:fs";
|
|
8
8
|
import { assertAndNormalizeFileUrl } from "../../path_and_url/file_url_validation.js";
|
|
9
|
+
import { generateWindowsEPERMErrorMessage } from "../../window_eperm_error.js";
|
|
9
10
|
import { writeEntryPermissionsSync } from "./write_entry_permissions_sync.js";
|
|
10
11
|
|
|
11
12
|
const isWindows = process.platform === "win32";
|
|
@@ -53,7 +54,10 @@ export const readEntryStatSync = (
|
|
|
53
54
|
return stats;
|
|
54
55
|
} catch (e) {
|
|
55
56
|
console.error(
|
|
56
|
-
|
|
57
|
+
generateWindowsEPERMErrorMessage(e, {
|
|
58
|
+
operation: "stats",
|
|
59
|
+
path: sourcePath,
|
|
60
|
+
}),
|
|
57
61
|
);
|
|
58
62
|
throw error;
|
|
59
63
|
}
|
|
@@ -9,6 +9,7 @@ import { closeSync, openSync, rmdir, unlink } from "node:fs";
|
|
|
9
9
|
import { assertAndNormalizeFileUrl } from "../path_and_url/file_url_validation.js";
|
|
10
10
|
import { readDirectory } from "../read_write/read_directory.js";
|
|
11
11
|
import { readEntryStat } from "../read_write/stat/read_entry_stat.js";
|
|
12
|
+
import { generateWindowsEPERMErrorMessage } from "../window_eperm_error.js";
|
|
12
13
|
|
|
13
14
|
export const removeEntry = async (
|
|
14
15
|
source,
|
|
@@ -168,7 +169,6 @@ const removeDirectory = async (
|
|
|
168
169
|
console.error(
|
|
169
170
|
`trying to fix windows EPERM after readir on ${directoryPath}`,
|
|
170
171
|
);
|
|
171
|
-
|
|
172
172
|
let openOrCloseError;
|
|
173
173
|
try {
|
|
174
174
|
const fd = openSync(directoryPath);
|
|
@@ -182,7 +182,10 @@ const removeDirectory = async (
|
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
184
|
console.error(
|
|
185
|
-
|
|
185
|
+
generateWindowsEPERMErrorMessage(openOrCloseError, {
|
|
186
|
+
operation: "readdir",
|
|
187
|
+
path: directoryPath,
|
|
188
|
+
}),
|
|
186
189
|
);
|
|
187
190
|
throw error;
|
|
188
191
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import { assertAndNormalizeFileUrl } from "../path_and_url/file_url_validation.js";
|
|
15
15
|
import { readEntryStatSync } from "../read_write/stat/read_entry_stat_sync.js";
|
|
16
|
+
import { generateWindowsEPERMErrorMessage } from "../window_eperm_error.js";
|
|
16
17
|
|
|
17
18
|
export const removeEntrySync = (
|
|
18
19
|
source,
|
|
@@ -153,7 +154,10 @@ const removeDirectorySync = (
|
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
156
|
console.error(
|
|
156
|
-
|
|
157
|
+
generateWindowsEPERMErrorMessage(openOrCloseError, {
|
|
158
|
+
path: directoryPath,
|
|
159
|
+
operation: "readir",
|
|
160
|
+
}),
|
|
157
161
|
);
|
|
158
162
|
throw error;
|
|
159
163
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const generateWindowsEPERMErrorMessage = (
|
|
2
|
+
error,
|
|
3
|
+
{ operation, path },
|
|
4
|
+
) => {
|
|
5
|
+
const pathLengthIsExceedingUsualLimit = String(path).length >= 256;
|
|
6
|
+
let message = "";
|
|
7
|
+
|
|
8
|
+
if (operation) {
|
|
9
|
+
message += `error while trying to fix windows EPERM after ${operation} on ${path}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (pathLengthIsExceedingUsualLimit) {
|
|
13
|
+
message += "\n";
|
|
14
|
+
message += `Maybe because path length is exceeding the usual limit of 256 characters of windows OS?`;
|
|
15
|
+
message += "\n";
|
|
16
|
+
}
|
|
17
|
+
message += "\n";
|
|
18
|
+
message += error.stack;
|
|
19
|
+
return message;
|
|
20
|
+
};
|