simple-icons/scripts/release/strip-theme-links.js
Álvaro Mondéjar 30dd8a1fbf
Use permanent README icons links in releases (#9788)
* Ensure permanent release README links

* Minor change
2023-10-28 19:24:55 +01:00

25 lines
692 B
JavaScript

/**
* @fileoverview
* Simple Icons strip theme URL script.
*/
import path from 'node:path';
import { writeFile, readFile } from 'node:fs/promises';
import { getDirnameFromImportMeta } from '../../sdk.mjs';
const LINKS_BRANCH = process.argv[2] || 'develop';
const __dirname = getDirnameFromImportMeta(import.meta.url);
const rootDir = path.resolve(__dirname, '..', '..');
const readmeFile = path.resolve(rootDir, 'README.md');
const readme = await readFile(readmeFile, 'utf8');
await writeFile(
readmeFile,
readme.replace(
/https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g,
`https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`,
),
);