fix(changelog): wrong semver sequence generation (#21)

now made ascending with "Unreleased" on top
This commit is contained in:
2024-05-04 21:55:04 +03:00
parent 47a8b05856
commit 87edf8cfad

View File

@@ -20,7 +20,7 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
import { Command } from "commander"; import { Command } from "commander";
import simpleGit from "simple-git"; import simpleGit from "simple-git";
import { CommitStack } from "../types"; import { CommitStack } from "../types";
import { sort } from "semver"; import { gt, sort } from "semver";
const command = new Command("changelog") const command = new Command("changelog")
.alias("ch") .alias("ch")
@@ -113,7 +113,17 @@ const command = new Command("changelog")
lastTag = tag; lastTag = tag;
} }
parsedCommitStacks = parsedCommitStacks.reverse(); // Might be confusing so I will leave mdn docs here
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
parsedCommitStacks = parsedCommitStacks.sort((a, b) => {
if (a.version === unreleased) {
return -1;
} else if (b.version === unreleased) {
return 1;
} else {
return gt(a.version, b.version) ? -1 : 1;
}
});
if (lastOnly) { if (lastOnly) {
parsedCommitStacks = [parsedCommitStacks[0]]; parsedCommitStacks = [parsedCommitStacks[0]];