This repository was archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (46 loc) · 1.38 KB
/
index.js
File metadata and controls
54 lines (46 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { icon, library } from "@fortawesome/fontawesome-svg-core";
import {
faChevronRight as fasChevronRight,
faCheckCircle as fasCheckCircle
} from "@fortawesome/pro-solid-svg-icons";
import { faChevronRight } from "@fortawesome/pro-regular-svg-icons";
import fs from "fs";
const writeFile = (path, data, opts = "utf8") => {
return new Promise((resolve, reject) => {
fs.writeFile(path, data, opts, err => {
if (err) reject(err);
else resolve();
});
});
};
function generateFontAwesomeModifiers() {
const icons = [fasChevronRight, fasCheckCircle, faChevronRight];
icons.forEach(async iconRef => {
library.add(iconRef);
const iconContents = icon({
prefix: iconRef.prefix,
iconName: iconRef.iconName
}).abstract[0];
fs.appendFile(
"./Icon.twig",
`
{% if "${iconRef.prefix}-${iconRef.iconName}" in modifier %}
{% include 'atoms/SVG/SVG.twig' with {
modifier: modifier,
view_box: "${iconContents.attributes.viewBox}",
path: "${iconContents.children[0].attributes.d}"
} %}
{% endif %}`
);
const jsonContents = JSON.stringify(
{
modifier: `${iconRef.prefix}-${iconRef.iconName}`,
icon: iconContents
},
null,
"\t"
);
await writeFile(`./modifiers/Icon~${iconRef.prefix}-${iconRef.iconName}.json`, jsonContents);
});
}
generateFontAwesomeModifiers();