@jsenv/filesystem 4.6.4 → 4.6.6
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 +2 -2
- package/src/assert_directory_presence.js +1 -1
- package/src/assert_file_presence.js +1 -1
- package/src/buffer_to_etag.js +1 -1
- package/src/lifecycle/register_directory_lifecycle.js +1 -1
- package/src/path_and_url/ensure_windows_drive_letter.js +3 -3
- package/src/remove/clear_directory_sync.js +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/filesystem",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "node --conditions=development ./scripts/test.mjs"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@jsenv/urls": "2.2.
|
|
35
|
+
"@jsenv/urls": "2.2.4",
|
|
36
36
|
"@jsenv/url-meta": "8.4.0",
|
|
37
37
|
"@jsenv/abort": "4.3.0",
|
|
38
38
|
"@jsenv/utils": "2.1.1"
|
|
@@ -16,7 +16,7 @@ export const assertDirectoryPresence = async (source) => {
|
|
|
16
16
|
}
|
|
17
17
|
if (!sourceStats.isDirectory()) {
|
|
18
18
|
throw new Error(
|
|
19
|
-
`directory
|
|
19
|
+
`directory expect at ${sourcePath} and found ${statsToType(
|
|
20
20
|
sourceStats,
|
|
21
21
|
)} instead`,
|
|
22
22
|
);
|
|
@@ -16,7 +16,7 @@ export const assertFilePresence = async (source) => {
|
|
|
16
16
|
}
|
|
17
17
|
if (!sourceStats.isFile()) {
|
|
18
18
|
throw new Error(
|
|
19
|
-
`file
|
|
19
|
+
`file expect at ${sourcePath} and found ${statsToType(
|
|
20
20
|
sourceStats,
|
|
21
21
|
)} instead`,
|
|
22
22
|
);
|
package/src/buffer_to_etag.js
CHANGED
|
@@ -11,7 +11,7 @@ const ETAG_FOR_EMPTY_CONTENT = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
|
|
11
11
|
|
|
12
12
|
export const bufferToEtag = (buffer) => {
|
|
13
13
|
if (!Buffer.isBuffer(buffer)) {
|
|
14
|
-
throw new TypeError(`buffer
|
|
14
|
+
throw new TypeError(`buffer expect,got ${buffer}`);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (buffer.length === 0) {
|
|
@@ -24,7 +24,7 @@ export const registerDirectoryLifecycle = (
|
|
|
24
24
|
notifyExistent = false,
|
|
25
25
|
keepProcessAlive = true,
|
|
26
26
|
recursive = false,
|
|
27
|
-
// filesystem might dispatch more events than
|
|
27
|
+
// filesystem might dispatch more events than expect
|
|
28
28
|
// Code can use "cooldownBetweenFileEvents" to prevent that
|
|
29
29
|
// BUT it is UNADVISED to rely on this as explained later (search for "is lying" in this file)
|
|
30
30
|
// For this reason"cooldownBetweenFileEvents" should be reserved to scenarios
|
|
@@ -20,7 +20,7 @@ export const ensureWindowsDriveLetter = (url, baseUrl) => {
|
|
|
20
20
|
try {
|
|
21
21
|
url = String(new URL(url));
|
|
22
22
|
} catch (e) {
|
|
23
|
-
throw new Error(`absolute url
|
|
23
|
+
throw new Error(`absolute url expect but got ${url}`);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (!isWindows) {
|
|
@@ -31,7 +31,7 @@ export const ensureWindowsDriveLetter = (url, baseUrl) => {
|
|
|
31
31
|
baseUrl = String(new URL(baseUrl));
|
|
32
32
|
} catch (e) {
|
|
33
33
|
throw new Error(
|
|
34
|
-
`absolute baseUrl
|
|
34
|
+
`absolute baseUrl expect but got ${baseUrl} to ensure windows drive letter on ${url}`,
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -53,7 +53,7 @@ export const ensureWindowsDriveLetter = (url, baseUrl) => {
|
|
|
53
53
|
);
|
|
54
54
|
if (!driveLetter) {
|
|
55
55
|
throw new Error(
|
|
56
|
-
`drive letter
|
|
56
|
+
`drive letter expect on baseUrl but got ${baseUrl} to ensure windows drive letter on ${url}`,
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
return `file:///${driveLetter}:${afterProtocol}`;
|
|
@@ -18,7 +18,16 @@ export const clearDirectorySync = (initialDirectoryUrl, pattern = "**/*") => {
|
|
|
18
18
|
initialDirectoryUrl,
|
|
19
19
|
);
|
|
20
20
|
const visitDirectory = (directoryUrl) => {
|
|
21
|
-
|
|
21
|
+
let entryNames;
|
|
22
|
+
try {
|
|
23
|
+
entryNames = readdirSync(new URL(directoryUrl));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (e.code === "ENOENT") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
for (const entryName of entryNames) {
|
|
23
32
|
const entryUrl = new URL(entryName, directoryUrl);
|
|
24
33
|
let entryStat;
|