Convert simple-icons manual backup from submodule to tracked files

This commit is contained in:
MayaChat
2025-11-24 14:51:23 -05:00
parent 30bbe7a0a4
commit f363db5e47
3467 changed files with 42987 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
#!/usr/bin/env node
// @ts-check
/**
* @file
* Replaces the SVG count milestone "Over <NUMBER> SVG icons..." located
* at README every time the number of current icons is more than `updateRange`
* more than the previous milestone.
*/
import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
import {getIconsData} from '../../sdk.mjs';
const regexMatcher = /Over\s(\d+)\s/;
const updateRange = 100;
const rootDirectory = path.resolve(import.meta.dirname, '..', '..');
const readmeFile = path.resolve(rootDirectory, 'README.md');
const readmeContent = await fs.readFile(readmeFile, 'utf8');
try {
const match = regexMatcher.exec(readmeContent);
if (match === null) {
console.error(
'Failed to obtain number of SVG icons of current milestone in README:',
'No match found',
);
process.exit(1);
} else {
const overNIconsInReadme = Number.parseInt(match[1], 10);
const iconsData = await getIconsData();
const nIcons = iconsData.length;
const nIconsRounded = Math.floor(nIcons / updateRange) * updateRange;
if (overNIconsInReadme !== nIconsRounded) {
const newContent = readmeContent.replace(
regexMatcher,
`Over ${nIconsRounded} `,
);
await fs.writeFile(readmeFile, newContent);
}
}
} catch (error) {
console.error(
'Failed to update number of SVG icons of current milestone in README:',
error,
);
process.exit(1);
}