-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
53 lines (51 loc) · 1.57 KB
/
build.js
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
const path = require("path");
const download = require("download");
const fs = require("fs/promises");
const svgEmojis = [
{
url: "https://github.com/hfg-gmuend/openmoji/releases/latest/download/openmoji-svg-black.zip",
destination: path.join(__dirname, "openmoji", "black"),
},
{
url: "https://github.com/hfg-gmuend/openmoji/releases/latest/download/openmoji-svg-color.zip",
destination: path.join(__dirname, "openmoji", "color"),
},
{
url: "https://github.com/mozilla/fxemoji/archive/refs/heads/gh-pages.zip",
destination: path.join(__dirname, "fxemoji"),
decompressOptions: {
filter: ({ path }) =>
path.includes("/svgs/FirefoxEmoji/") &&
path.endsWith(".svg") &&
!/\.layer\d+\.svg$/.test(path),
map: (file) => {
file.path = path.basename(file.path);
return file;
},
},
},
{
url: "https://github.com/twitter/twemoji/archive/refs/heads/master.zip",
destination: path.join(__dirname, "twemoji"),
decompressOptions: {
filter: ({ path }) =>
path.includes("/assets/svg/") && path.endsWith(".svg"),
map: (file) => {
file.path = path.basename(file.path);
return file;
},
},
},
];
svgEmojis.map(async ({ url, destination, decompressOptions }) => {
await fs.rmdir(destination, { recursive: true });
await download(url, destination, {
extract: true,
...decompressOptions,
});
const files = await fs.readdir(destination);
return fs.writeFile(
path.join(destination, "index.json"),
JSON.stringify(files, null, 2)
);
});