umami/scripts/build-svg.js

23 lines
513 B
JavaScript
Raw Normal View History

2022-07-05 06:51:14 +02:00
const { readdir, readFileSync, writeFileSync, unlinkSync } = require('fs-extra');
async function main() {
const dir = 'assets';
/**
* @type {string[]}
*/
const files = await readdir(dir);
for (const file of files) {
if (file.endsWith('.svg')) {
const content = readFileSync(`${dir}/${file}`, {
encoding: 'utf-8',
});
writeFileSync(`${dir}/${file.replace('.svg', '.jsx')}`, `export default () => ${content}`);
unlinkSync(`${dir}/${file}`);
}
}
}
main();