fix color.ini generation

This commit is contained in:
Send_Nukez 2021-11-03 01:40:54 +01:00
parent 79eb030a5f
commit 3c64c12a64

View file

@ -1,13 +1,18 @@
const REGEX = /(?<key>.*?):.*?#(?<color>.*?)/gm;
const TRIM_REGEX = /colors: \((?<colors>.*?)\);/s;
const COLOR_REGEX = /(?<key>[\w-]*?):.*?#(?<color>.*?),?$/gm;
module.exports = function (content, map, meta) {
const matches = [...content.matchAll(REGEX)];
const outLines = ["[base]"];
const colors = content
.match(TRIM_REGEX)
.groups.colors.split("\n")
.map((l) => l.trim())
.join("\n");
const matches = [...colors.matchAll(COLOR_REGEX)];
const ini = ["[base]"];
for (let i = 0; i < matches.length; i++) {
const { key, color } = matches[i].groups;
outLines.push(`${key} = ${color}`);
ini.push(`${key} = ${color}`);
}
return outLines.join("\n");
return ini.join("\n");
};