fix(changelog): wrong semver sequence generation (#21)
now made ascending with "Unreleased" on top
This commit is contained in:
@@ -20,7 +20,7 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
||||
import { Command } from "commander";
|
||||
import simpleGit from "simple-git";
|
||||
import { CommitStack } from "../types";
|
||||
import { sort } from "semver";
|
||||
import { gt, sort } from "semver";
|
||||
|
||||
const command = new Command("changelog")
|
||||
.alias("ch")
|
||||
@@ -113,7 +113,17 @@ const command = new Command("changelog")
|
||||
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) {
|
||||
parsedCommitStacks = [parsedCommitStacks[0]];
|
||||
|
||||
Reference in New Issue
Block a user