[autoTag] Fixed age-old bug

This commit is contained in:
Alyxia Sother 2021-07-05 23:44:15 +02:00
parent bd4c9d266a
commit 80d9974c05
No known key found for this signature in database
GPG Key ID: 355968D14144B739
2 changed files with 10 additions and 6 deletions

View File

@ -1,15 +1,19 @@
const basicIncludes = (bundleCode, code, display = (code[0].toUpperCase() + code.substring(1))) => {
const basicIncludes = (bundleCode, code, display = code[0].toUpperCase() + code.substring(1)) => {
if (bundleCode.includes(code)) return display;
};
export default (bundleCode) => { // Scans final bundle JS to try and auto-detect things, then adding tags
export default (bundleCode, currentTags) => {
// Scans final bundle JS to try and auto-detect things, then adding tags
const tags = [
basicIncludes(bundleCode, 'react'),
basicIncludes(bundleCode, 'document', 'DOM'),
(bundleCode.includes('document.createTextNode') && /document\.createElement\(['"`]style['"`]\)/.test(bundleCode)) ? 'CSS' : undefined,
/document\.createElement\(['"`]style['"`]\)/.test(bundleCode) ? 'CSS' : undefined,
].filter((x) => x !== undefined);
currentTags.includes('themes') ? 'theme' : undefined,
]
.filter((x) => x !== undefined)
.concat(currentTags.filter((x) => x !== 'themes'));
return tags;
};
};

View File

@ -79,7 +79,7 @@ export default () => {
let cards = [];
let metas = [];
let name = 'GooseMod Store';
let name = 'NovaGM Store';
let description = '';
for (const repo of repos) {