From 6c80241c88d635e608450582cc1ac58e74b498ea Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 27 Feb 2023 14:00:06 -0500 Subject: [PATCH] refactor: isPerfBenchmark --- packages/markdown/remark/src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 72c4ebf86..ebf3dbf79 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -39,6 +39,9 @@ export const markdownConfigDefaults: Omit, 'draft smartypants: true, }; +// Skip nonessential plugins during performance benchmark runs +const isPerformanceBenchmark = Boolean(process.env.ASTRO_CI_PERFORMANCE_RUN); + /** Shared utility for rendering markdown */ export async function renderMarkdown( content: string, @@ -56,7 +59,6 @@ export async function renderMarkdown( contentDir, frontmatter: userFrontmatter = {}, } = opts; - const performanceRun = Boolean(process.env.ASTRO_CI_PERFORMANCE_RUN); const input = new VFile({ value: content, path: fileURL }); const scopedClassName = opts.$?.scopedClassName; @@ -65,7 +67,7 @@ export async function renderMarkdown( .use(toRemarkInitializeAstroData({ userFrontmatter })) .use([]); - if (!performanceRun) { + if (!isPerformanceBenchmark) { if (gfm) { parser.use(remarkGfm); } @@ -82,7 +84,7 @@ export async function renderMarkdown( parser.use([[plugin, pluginOpts]]); }); - if (!performanceRun) { + if (!isPerformanceBenchmark) { if (scopedClassName) { parser.use([scopedStyles(scopedClassName)]); } @@ -112,7 +114,7 @@ export async function renderMarkdown( parser.use([[plugin, pluginOpts]]); }); - if (!performanceRun) { + if (!isPerformanceBenchmark) { parser.use([rehypeHeadingIds]); }