Skip to content

Commit 52c06d8

Browse files
committed
Fix semver sort in readChecksums and validate overwrite field
- readChecksums: Sort version filenames by numeric semver components instead of lexicographic order (1.10.0 now correctly sorts after 1.9.0) - configApply: Validate overwrite field against known values (always, if-changed, never) and warn on unrecognized values
1 parent 8c9683e commit 52c06d8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

setup.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ function readChecksums(codeforgeDir) {
118118
const files = fs
119119
.readdirSync(checksumsDir)
120120
.filter((f) => f.endsWith(".json"))
121-
.sort();
121+
.sort((a, b) => {
122+
const pa = a.replace(".json", "").split(".").map(Number);
123+
const pb = b.replace(".json", "").split(".").map(Number);
124+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
125+
const diff = (pa[i] || 0) - (pb[i] || 0);
126+
if (diff !== 0) return diff;
127+
}
128+
return 0;
129+
});
122130

123131
if (files.length === 0) {
124132
return { files: {} };
@@ -506,12 +514,24 @@ function configApply() {
506514
let deployed = 0;
507515
let skipped = 0;
508516

517+
const validOverwrite = ["always", "if-changed", "never"];
518+
509519
for (const entry of entries) {
510520
if (entry.enabled === false) {
511521
skipped++;
512522
continue;
513523
}
514524

525+
if (entry.overwrite && !validOverwrite.includes(entry.overwrite)) {
526+
console.log(
527+
' Warning: Unknown overwrite value "' +
528+
entry.overwrite +
529+
'" for ' +
530+
entry.src +
531+
', defaulting to "always"',
532+
);
533+
}
534+
515535
const srcPath = path.join(codeforgeDir, entry.src);
516536
if (!fs.existsSync(srcPath)) {
517537
console.log(" Skip: " + entry.src + " (not found)");

0 commit comments

Comments
 (0)