Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
fix sort order of citation styles. #374
Browse files Browse the repository at this point in the history
  • Loading branch information
dsifford committed Dec 9, 2017
1 parent 677e572 commit 8f1b9d4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/scripts/update-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@ function parseStyleObj(obj: StyleResponse): StyleData {
},
<FileEntry[]>[],
)
.sort((a, b) => {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
})
.map(style => {
const label = style.object.text.match(/<title>(.+)<\/title>/)![1].replace(
/&amp;/g,
Expand All @@ -139,6 +130,11 @@ function parseStyleObj(obj: StyleResponse): StyleData {
label,
value,
};
})
.sort((a, b) => {
const prev = a.label.toLowerCase();
const next = b.label.toLowerCase();
return prev < next ? -1 : 1;
});
if (!renamed) {
throw new Error('renamed-styles.json file never found!');
Expand Down Expand Up @@ -172,8 +168,12 @@ function getNewStyles(before: StyleData, after: StyleObj[]): string[] {
const newStyles = getNewStyles(oldData, newData.styles);
console.log('================ New Styles Added ================');
console.log(newStyles.join('\n'));
// fs.writeFileSync(
// path.resolve(__dirname, '../../src/vendor/', 'citation-styles.json'),
// JSON.stringify(newData, null, 4),
// );
fs.writeFileSync(
path.resolve(__dirname, '../../src/vendor/', 'citation-styles.json'),
path.resolve(__dirname, 'citation-styles-temp.json'),
JSON.stringify(newData, null, 4),
);
})();

0 comments on commit 8f1b9d4

Please # to comment.