mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-10-26 21:19:04 +08:00
chore(sync): synchronize metadata files with added categories / aliases to central metadata file
This commit is contained in:
25
scripts/sync-metadata.mjs
Normal file
25
scripts/sync-metadata.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
import fs from "fs/promises";
|
||||
|
||||
const content = await fs.readFile("metadata.json", "utf-8");
|
||||
const metadata = JSON.parse(content);
|
||||
|
||||
const keys = Object.keys(metadata);
|
||||
let iteration = 0;
|
||||
for (const key of keys) {
|
||||
const file = `meta/${key}.json`;
|
||||
try {
|
||||
const fileContent = await fs.readFile(file, "utf-8");
|
||||
const fileMetadata = JSON.parse(fileContent);
|
||||
if (fileMetadata !== metadata[key]) {
|
||||
await fs.writeFile(file, JSON.stringify(metadata[key], null, 2));
|
||||
} else {
|
||||
console.log(`No changes for ${file}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error reading ${file}: ${err.message}`);
|
||||
}
|
||||
iteration++;
|
||||
if (iteration % 100 === 0) {
|
||||
console.log(`Processed ${iteration}/${keys.length} files`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user