[*Theme] Escape $, move escaping to generic instead of in each preproc

This commit is contained in:
Ducko 2021-06-20 12:16:56 +01:00 committed by Alyxia Sother
parent 42e2c02719
commit d05b6c17c5
No known key found for this signature in database
GPG key ID: 355968D14144B739
3 changed files with 11 additions and 9 deletions

View file

@ -1,13 +1,13 @@
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs'; import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
export default (themePath, repo) => { export default (themePath, repo) => {
const content = readFileSync(themePath); const content = readFileSync(themePath, 'utf8');
const metaReg = /@([^ ]*) (.*)/g; const metaReg = /@([^ ]*) (.*)/g;
let manifest = { let manifest = {
main: 'index.js', main: 'index.js',
tags: ['theme', 'port'] tags: ['theme', 'port'],
}; };
let match; let match;

View file

@ -55,7 +55,9 @@ const discordVars = [
'--deprecated-text-input-prefix', '--deprecated-text-input-prefix',
]; ];
export default (manifest, content, repo) => { export default (manifest, _content, repo) => {
const content = _content.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$');
let variables = content.match(/--([^*!\n}]*): ([^*!\n}]*);/g) || []; let variables = content.match(/--([^*!\n}]*): ([^*!\n}]*);/g) || [];
if (variables.length > 0) if (variables.length > 0)
variables = variables.map((x) => { variables = variables.map((x) => {

View file

@ -27,7 +27,7 @@ export default (manifestPath, repo) => {
pcManifest.theme = cssPath; pcManifest.theme = cssPath;
} }
const content = readFileSync(pcManifest.theme, 'utf8').replace(/\\/g, '\\\\').replace(/`/g, '\\`'); const content = readFileSync(pcManifest.theme, 'utf8');
const jsCode = `// Generated by MS2Builder - pcTheme preprocessor / porter const jsCode = `// Generated by MS2Builder - pcTheme preprocessor / porter
let style; let style;