Created
March 25, 2023 03:23
-
-
Save albannurkollari/84d34ae91eef82a8f16d334618a1f1d0 to your computer and use it in GitHub Desktop.
e2e-filters-with-unified-plugins-pr-body-parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { unified } from 'unified'; | |
import remarkParse from 'remark-parse'; | |
import remarkGfm from 'remark-gfm'; | |
import remarkRehype from 'remark-rehype'; | |
import rehypeFormat from 'rehype-format'; | |
import rehypeStringify from 'rehype-stringify'; | |
import rehypeRaw from 'rehype-raw'; | |
import { load as cheerioLoad } from 'cheerio'; | |
(async () => { | |
const { process: parser } = unified() | |
.use(remarkParse) | |
.use(remarkRehype, { allowDangerousHtml: true }) | |
.use(rehypeRaw) | |
.use(remarkGfm) | |
.use(rehypeFormat) | |
.use(rehypeStringify); | |
const file = await gh().then(parser); | |
const $ = cheerioLoad(file.value); | |
const detailsNodes = $('#e2e-filters').children( | |
'details:has(input[checked])' | |
); | |
const env = [...detailsNodes].reduce((acc, detail) => { | |
const { id } = detail.attribs; | |
const checkboxes = [...$(`#${id} input[checked]`)]; | |
const values = checkboxes.map(({ nextSibling: ns }: any) => | |
ns?.nodeValue.trim() | |
); | |
return { ...acc, [id]: values.join(':') }; | |
}, {}); | |
console.log(env); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment