@jsenv/snapshot 2.11.19 → 2.11.20
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/snapshot",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.20",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@jsenv/assert": "4.4.2",
|
|
34
|
-
"@jsenv/ast": "6.3.
|
|
34
|
+
"@jsenv/ast": "6.3.6",
|
|
35
35
|
"@jsenv/exception": "1.1.3",
|
|
36
36
|
"@jsenv/humanize": "1.2.8",
|
|
37
|
-
"@jsenv/filesystem": "4.10.
|
|
37
|
+
"@jsenv/filesystem": "4.10.12",
|
|
38
38
|
"@jsenv/terminal-recorder": "1.4.17",
|
|
39
|
-
"@jsenv/urls": "2.5.
|
|
39
|
+
"@jsenv/urls": "2.5.3",
|
|
40
40
|
"@jsenv/utils": "2.1.2",
|
|
41
41
|
"ansi-regex": "6.1.0",
|
|
42
42
|
"pixelmatch": "6.0.0",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
assertAndNormalizeFileUrl,
|
|
5
5
|
comparePathnames,
|
|
6
6
|
ensureEmptyDirectorySync,
|
|
7
|
+
readEntryStatSync,
|
|
7
8
|
removeDirectorySync,
|
|
8
9
|
removeFileSync,
|
|
9
10
|
writeFileSync,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
urlToRelativeUrl,
|
|
16
17
|
} from "@jsenv/urls";
|
|
17
18
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
|
|
18
|
-
import { readdirSync, readFileSync
|
|
19
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
19
20
|
import { fileURLToPath } from "node:url";
|
|
20
21
|
import { comparePngFiles } from "./compare_png_files.js";
|
|
21
22
|
import {
|
|
@@ -129,7 +130,7 @@ ${fileUrl}`);
|
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
try {
|
|
132
|
-
fileSnapshot.stat =
|
|
133
|
+
fileSnapshot.stat = readEntryStatSync(new URL(fileUrl));
|
|
133
134
|
} catch (e) {
|
|
134
135
|
if (e.code === "ENOENT") {
|
|
135
136
|
return fileSnapshot;
|
|
@@ -342,7 +343,7 @@ ${extraUrls.join("\n")}`);
|
|
|
342
343
|
},
|
|
343
344
|
};
|
|
344
345
|
try {
|
|
345
|
-
directorySnapshot.stat =
|
|
346
|
+
directorySnapshot.stat = readEntryStatSync(new URL(directoryUrl));
|
|
346
347
|
} catch (e) {
|
|
347
348
|
if (e.code === "ENOENT") {
|
|
348
349
|
return directorySnapshot;
|
|
@@ -369,7 +370,7 @@ ${extraUrls.join("\n")}`);
|
|
|
369
370
|
const directoryItemUrl = new URL(directoryItem, directoryUrl);
|
|
370
371
|
let directoryItemStat;
|
|
371
372
|
try {
|
|
372
|
-
directoryItemStat =
|
|
373
|
+
directoryItemStat = readEntryStatSync(directoryItemUrl);
|
|
373
374
|
} catch (e) {
|
|
374
375
|
if (e.code === "ENOENT") {
|
|
375
376
|
continue;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensurePathnameTrailingSlash,
|
|
3
3
|
removePathnameTrailingSlash,
|
|
4
|
+
urlToFileSystemPath,
|
|
4
5
|
yieldAncestorUrls,
|
|
5
6
|
} from "@jsenv/urls";
|
|
6
7
|
import { escapeRegexpSpecialChars } from "@jsenv/utils/src/string/escape_regexp_special_chars.js";
|
|
7
8
|
import { readFileSync } from "node:fs";
|
|
8
9
|
import { homedir } from "node:os";
|
|
9
|
-
import {
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
10
11
|
|
|
11
12
|
// remember this: https://stackoverflow.com/a/31976060/24573072
|
|
12
13
|
// when deciding which replacement to use and willBeWrittenOnFilesystem is true
|
|
@@ -85,7 +86,7 @@ export const createReplaceFilesystemWellKnownValues = ({
|
|
|
85
86
|
const path =
|
|
86
87
|
String(url) === String(cwdUrl)
|
|
87
88
|
? cwdPath
|
|
88
|
-
:
|
|
89
|
+
: urlToFileSystemPath(urlWithoutTrailingSlash);
|
|
89
90
|
const windowPathRegex = new RegExp(
|
|
90
91
|
`${escapeRegexpSpecialChars(path)}(((?:\\\\(?:[\\w !#()-]+|[.]{1,2})+)*)(?:\\\\)?)`,
|
|
91
92
|
"gm",
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
writeFileSync,
|
|
11
11
|
} from "@jsenv/filesystem";
|
|
12
12
|
import { URL_META } from "@jsenv/url-meta";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
ensurePathnameTrailingSlash,
|
|
15
|
+
urlToFileSystemPath,
|
|
16
|
+
yieldAncestorUrls,
|
|
17
|
+
} from "@jsenv/urls";
|
|
14
18
|
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
15
19
|
import { pathToFileURL } from "node:url";
|
|
16
20
|
import {
|
|
@@ -177,7 +181,9 @@ export const spyFilesystemCalls = (
|
|
|
177
181
|
if (!stateBefore.found && recursive) {
|
|
178
182
|
const ancestorNotFoundArray = [];
|
|
179
183
|
for (const ancestorUrl of yieldAncestorUrls(directoryUrl)) {
|
|
180
|
-
const ancestorState = getDirectoryState(
|
|
184
|
+
const ancestorState = getDirectoryState(
|
|
185
|
+
urlToFileSystemPath(new URL(ancestorUrl)),
|
|
186
|
+
);
|
|
181
187
|
if (ancestorState.found) {
|
|
182
188
|
break;
|
|
183
189
|
}
|
|
@@ -348,7 +354,7 @@ const getFileState = (filePath) => {
|
|
|
348
354
|
const fileUrl = pathToFileURL(filePath);
|
|
349
355
|
try {
|
|
350
356
|
const fileBuffer = readFileSync(fileUrl);
|
|
351
|
-
const { mtimeMs } = statSync(
|
|
357
|
+
const { mtimeMs } = statSync(filePath);
|
|
352
358
|
return {
|
|
353
359
|
url: String(fileUrl),
|
|
354
360
|
found: true,
|