Skip to content

Commit

Permalink
fix(main): fix xhtml option having no effect on module usage
Browse files Browse the repository at this point in the history
cheerio was removing the format of the xml tags due to a missing option. Added necessary options to
keep xhtml format on the tags updated on index.html file.

fix #351
  • Loading branch information
onderceylan committed Aug 31, 2020
1 parent 51efd29 commit 4dfa9c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/helpers/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,17 @@ ${htmlMeta[meta.name]}`;
const addMetaTagsToIndexPage = async (
htmlMeta: HTMLMeta,
indexHtmlFilePath: string,
xhtml: boolean,
): Promise<void> => {
if (!(await file.isPathAccessible(indexHtmlFilePath, file.WRITE_ACCESS))) {
throw Error(`Cannot write to index html file ${indexHtmlFilePath}`);
}

const indexHtmlFile = await file.readFile(indexHtmlFilePath);
const $ = cheerio.load(indexHtmlFile, { decodeEntities: false });
const $ = cheerio.load(indexHtmlFile, {
decodeEntities: false,
xmlMode: xhtml,
});

const HEAD_SELECTOR = 'head';
const hasElement = (selector: string): boolean => {
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ async function generateImages(
}

if (modOptions.index) {
await meta.addMetaTagsToIndexPage(htmlMeta, modOptions.index);
await meta.addMetaTagsToIndexPage(
htmlMeta,
modOptions.index,
modOptions.xhtml,
);
logger.success(
`iOS meta tags are saved to index html file ${modOptions.index}`,
);
Expand Down

0 comments on commit 4dfa9c4

Please sign in to comment.