refactor(update): return null in update funcs if no updates to clean up output

This commit is contained in:
matt1432 2025-04-16 11:23:14 -04:00
parent a93ec6ad3f
commit c816c15c50
9 changed files with 100 additions and 67 deletions
apps/update-sources/src

View file

@ -6,7 +6,7 @@ import { styleText } from 'node:util';
/* Constants */
const FLAKE = process.env.FLAKE;
export default () => {
export default (): string | null => {
console.log(styleText(['magenta'], '\nUpdating firefox addons using mozilla-addons-to-nix:\n'));
const DIR = `${FLAKE}/scopedPackages/firefox-addons`;
@ -54,9 +54,12 @@ export default () => {
return [nameMap[pinfo[0]], pinfo[2]];
}));
return Object.keys(OLD_VERS)
const changelogs = Object.keys(OLD_VERS)
.sort()
.filter((pname) => OLD_VERS[pname] !== NEW_VERS[pname])
.map((pname) => `${pname}: ${OLD_VERS[pname]} -> ${NEW_VERS[pname]}`)
.join('\n');
.map((pname) => `${pname}: ${OLD_VERS[pname]} -> ${NEW_VERS[pname]}`);
return changelogs.length > 0 ?
changelogs.join('\n') :
null;
};