mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-07-10 13:41:38 +00:00
fix color.ini generation
This commit is contained in:
parent
79eb030a5f
commit
3c64c12a64
1 changed files with 11 additions and 6 deletions
|
|
@ -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) {
|
module.exports = function (content, map, meta) {
|
||||||
const matches = [...content.matchAll(REGEX)];
|
const colors = content
|
||||||
const outLines = ["[base]"];
|
.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++) {
|
for (let i = 0; i < matches.length; i++) {
|
||||||
const { key, color } = matches[i].groups;
|
const { key, color } = matches[i].groups;
|
||||||
outLines.push(`${key} = ${color}`);
|
ini.push(`${key} = ${color}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outLines.join("\n");
|
return ini.join("\n");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue