@diplodoc/cli-tests 5.34.4 → 5.34.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/fixtures/utils/file.ts +2 -4
- package/fixtures/utils/test.ts +17 -4
- package/package.json +1 -1
package/fixtures/utils/file.ts
CHANGED
|
@@ -71,9 +71,7 @@ export async function compareDirectories(
|
|
|
71
71
|
nodir: true,
|
|
72
72
|
posix: true,
|
|
73
73
|
})
|
|
74
|
-
)
|
|
75
|
-
.map(bundleless)
|
|
76
|
-
.sort();
|
|
74
|
+
).sort();
|
|
77
75
|
|
|
78
76
|
let filesForSnapshot;
|
|
79
77
|
|
|
@@ -87,7 +85,7 @@ export async function compareDirectories(
|
|
|
87
85
|
// This is necessary for better test stability
|
|
88
86
|
// We do not care in what order these files were received and processed
|
|
89
87
|
// We sort only the final list and put it in the snapshot
|
|
90
|
-
filesForSnapshot = filesForSnapshot.map(hashless).sort();
|
|
88
|
+
filesForSnapshot = filesForSnapshot.map(bundleless).map(hashless).sort();
|
|
91
89
|
|
|
92
90
|
if (!ignoreFileList) {
|
|
93
91
|
expect(JSON.stringify(filesForSnapshot, null, 2)).toMatchSnapshot('filelist');
|
package/fixtures/utils/test.ts
CHANGED
|
@@ -39,11 +39,24 @@ export function bundleless(text: string): string {
|
|
|
39
39
|
for (const [entryKey, entry] of Object.entries(assets)) {
|
|
40
40
|
for (const [typeKey, type] of Object.entries(entry)) {
|
|
41
41
|
for (let index = 0; index < type.length; index++) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// Extract base name from manifest filename (e.g. "app-3ff8bc0b40bc2914.js" -> "app")
|
|
43
|
+
// Also handles suffixes like "vendor-00121562c7b7d3b5.rtl.css" -> base="vendor", suffix=".rtl", ext="css"
|
|
44
|
+
const filename = type[index];
|
|
45
|
+
const match = filename.match(/^(.+?)-[a-z0-9]{12,16}(\.[a-z]+)*\.([a-z]+)$/);
|
|
46
|
+
if (!match) {
|
|
47
|
+
// Fallback: exact string replacement for filenames without hash pattern
|
|
48
|
+
let prev = '';
|
|
49
|
+
while (prev !== text) {
|
|
50
|
+
prev = text;
|
|
51
|
+
text = text.replace(filename, `${entryKey}-${typeKey}-${index}`);
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
46
54
|
}
|
|
55
|
+
|
|
56
|
+
const [, base, suffixes, ext] = match;
|
|
57
|
+
const suffixPattern = suffixes ? suffixes.replace(/\./g, '\\.') : '';
|
|
58
|
+
const pattern = new RegExp(`${base}-[a-z0-9]{12,16}${suffixPattern}\\.${ext}`, 'g');
|
|
59
|
+
text = text.replace(pattern, `${entryKey}-${typeKey}-${index}`);
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
62
|
}
|