forked from Khan/live-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all-images.js
24 lines (22 loc) · 844 Bytes
/
build-all-images.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
/**
* Running this file will regenerate js/shared/all-images.js
*/
var fs = require("fs");
var path = require("path");
var images = [];
fs.readdirSync("images").forEach(function(group) {
if (fs.statSync(path.join("images", group)).isDirectory()) {
images.push({
groupName: group,
images: fs.readdirSync(
path.join("images", group)).filter(function(image) {
return fs.statSync(
path.join("images", group, image)).isFile();
}).map(function(image) { return image.replace(".png", ""); }),
});
}
});
fs.writeFileSync(path.join("js", "shared", "all-images.js"),
`// autogenerated: run 'node build-all-images.js'
// from the root folder to rebuild\n
window.AllImages = ${JSON.stringify(images, null, 4)};\n`);