Skip to content

Commit

Permalink
Fix crash running yarn flags --sort flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 15, 2024
1 parent 2e470a7 commit acaae63
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/flags/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,15 @@ for (const flag of allFlagsUniqueFlags) {
let sorted = table;
if (isDiff || argv.sort) {
const sortChannel = argToHeader(isDiff ? argv.diff[0] : argv.sort);
sorted = Object.fromEntries(
Object.entries(table).sort(([, rowA], [, rowB]) =>
rowB[sortChannel].toString().localeCompare(rowA[sortChannel])
)
);
const sortBy =
sortChannel === 'flag'
? ([flagA], [flagB]) => {
return flagA.localeCompare(flagB);
}
: ([, rowA], [, rowB]) => {
return rowB[sortChannel].toString().localeCompare(rowA[sortChannel]);
};
sorted = Object.fromEntries(Object.entries(table).sort(sortBy));
}

if (argv.csv) {
Expand Down

0 comments on commit acaae63

Please sign in to comment.