Skip to content

Commit

Permalink
fix(FA parser): search terms undefined in FA 5.9
Browse files Browse the repository at this point in the history
An issue with the FA 5.9 metadata was causing the script to exit because
the search terms couldn't be found because for 2 of the new icons. The
search terms where moved from search.terms to the top level. Issue was
raised with FA https://github.com/FortAwesome/Font-Awesome-Pro/issues/1380

Closes #16
  • Loading branch information
Sean Hamilton committed Jul 6, 2019
1 parent 2fb8f87 commit c6da734
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/parsers/FontAwesome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import aliases from '../static/aliases.json';
export interface IconMeta {
search: {
terms: string[];
}
};
terms?: string[];
styles: string[];
unicode: string;
private: boolean;
Expand Down Expand Up @@ -98,13 +99,17 @@ export default function parse(results: PromptResults, paths: PathResults): Promi
const iconMeta: IconMeta = iconMetadata[iconName];

if (!iconMeta.private) {
const searchTerms: string[] = iconMeta.search
? (iconMeta.search.terms || [])
: (iconMeta.terms || []);

// solid
if (iconMeta.styles.includes('solid')) {
icons.push(new Icon({
name: iconName,
type: IconType.SOLID,
unicode: iconMeta.unicode,
searchTerms: iconMeta.search.terms,
searchTerms,
}));
}

Expand All @@ -114,7 +119,7 @@ export default function parse(results: PromptResults, paths: PathResults): Promi
name: iconName,
type: IconType.OUTLINE,
unicode: iconMeta.unicode,
searchTerms: iconMeta.search.terms,
searchTerms,
}));
}

Expand All @@ -124,7 +129,7 @@ export default function parse(results: PromptResults, paths: PathResults): Promi
name: iconName,
type: IconType.THIN,
unicode: iconMeta.unicode,
searchTerms: iconMeta.search.terms,
searchTerms,
}));
}

Expand All @@ -134,7 +139,7 @@ export default function parse(results: PromptResults, paths: PathResults): Promi
name: iconName,
type: IconType.BRAND,
unicode: iconMeta.unicode,
searchTerms: iconMeta.search.terms,
searchTerms,
}));
}
}
Expand Down

0 comments on commit c6da734

Please sign in to comment.