2022-11-29 12:29:52 -06:00
|
|
|
import { ReleaseData } from '../types';
|
|
|
|
|
|
|
|
export const compareReleasesFn = (a: ReleaseData, b: ReleaseData) => {
|
2022-12-15 09:27:49 -06:00
|
|
|
const aPublished = new Date(a.published);
|
|
|
|
const bPublished = new Date(b.published);
|
|
|
|
const sameDate = aPublished.toDateString() === bPublished.toDateString();
|
|
|
|
const sameCommit = a.commit.label === b.commit.label;
|
|
|
|
|
|
|
|
if (sameDate && !sameCommit) {
|
|
|
|
return aPublished > bPublished ? -1 : 1;
|
2022-11-29 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
2022-12-15 09:27:49 -06:00
|
|
|
if (sameDate) {
|
|
|
|
return a.release.label.length - b.release.label.length;
|
2022-11-29 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
2022-12-15 09:27:49 -06:00
|
|
|
return aPublished > bPublished ? -1 : 1;
|
2022-11-29 12:29:52 -06:00
|
|
|
};
|