forked from studioIngrid/studio-icons_beta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-script.js
30 lines (24 loc) · 1020 Bytes
/
build-script.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
const fs = require('fs');
const path = require('path');
// Read the template files
const templateStart = fs.readFileSync('src/template-start.js', 'utf8');
const templateEnd = fs.readFileSync('src/template-end.js', 'utf8');
// Read all JSON files from the lottie-json directory
const lottieDir = path.join(__dirname, 'lottie-json');
const files = fs.readdirSync(lottieDir);
// Create the iconTemplates object
const iconTemplates = {};
files.forEach(file => {
if (path.extname(file) === '.json') {
const fileName = path.basename(file, '.json');
const fileContent = fs.readFileSync(path.join(lottieDir, file), 'utf8');
iconTemplates[fileName] = JSON.parse(fileContent);
}
});
// Generate the final content
const finalContent = `${templateStart}
var iconTemplates = ${JSON.stringify(iconTemplates, null, 2)};
${templateEnd}`;
// Write the final content to the output file
fs.writeFileSync('src/studio-icons_beta.js', finalContent);
console.log('studio-icons_beta.js has been generated successfully.');