forked from benwiley4000/win95-media-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encodeIcons.js
36 lines (32 loc) · 862 Bytes
/
encodeIcons.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
/* eslint-disable no-console */
const base64Img = require('base64-img');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const iconsSrcDir = path.join(__dirname, 'src', 'icons');
const iconsLibDir = path.join(__dirname, 'lib', 'icons');
mkdirp.sync(iconsLibDir);
fs.readdir(path.join(__dirname, 'src', 'icons'), (err, files) => {
if (err) {
console.error(err);
process.exit(1);
}
for (const file of files) {
base64Img.base64(path.join(iconsSrcDir, file), (err, data) => {
if (err) {
console.error(err);
process.exit(1);
}
fs.writeFile(
path.join(iconsLibDir, file + '.js'),
`module.exports='${data}'`,
err => {
if (err) {
console.error(err);
process.exit(1);
}
}
);
});
}
});