mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-10-23 09:28:38 -04:00
icon importing, landing page updates, vite config
This commit is contained in:
1 parent
68688244a8
commit
06aa06c31c
24 files changed
+1012
-162
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
|
||||
(async function main() {
|
||||
async function exists(path) {
|
||||
try {
|
||||
await fs.access(path);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const files = await fs.readdir('./src/assets/icons');
|
||||
const icons = files.filter((f) => f.endsWith('.svg'));
|
||||
let str = '';
|
||||
|
||||
for (let binding of icons) {
|
||||
let name = binding.split('.')[0];
|
||||
str += `import { ReactComponent as ${
|
||||
name.charAt(0).toUpperCase() + name.slice(1)
|
||||
} } from './${name}.svg';\n`;
|
||||
}
|
||||
str += '\n\nexport default {\n';
|
||||
|
||||
for (let binding of icons) {
|
||||
let name = binding.split('.')[0];
|
||||
let componentName = name.charAt(0).toUpperCase() + name.slice(1);
|
||||
str += ` ${name}: ${componentName},\n`;
|
||||
}
|
||||
|
||||
str += '}\n';
|
||||
|
||||
let outPath = './src/assets/icons/index.ts';
|
||||
|
||||
let indexExists = await exists(outPath);
|
||||
|
||||
if (indexExists) {
|
||||
await fs.rm(outPath);
|
||||
}
|
||||
|
||||
await fs.writeFile(outPath, str);
|
||||
})();
|
||||
Reference in new issue
Block a user