mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-26 21:41:49 +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) {
|
||||
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");
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue