2023-07-28 15:50:15 +02:00
|
|
|
/**
|
|
|
|
* @fileoverview
|
2023-11-27 12:50:10 +02:00
|
|
|
* Reformat README to regular markdown.
|
2023-07-28 15:50:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
import path from 'node:path';
|
|
|
|
import { writeFile, readFile } from 'node:fs/promises';
|
|
|
|
import { getDirnameFromImportMeta } from '../../sdk.mjs';
|
|
|
|
|
2023-10-28 20:24:55 +02:00
|
|
|
const LINKS_BRANCH = process.argv[2] || 'develop';
|
|
|
|
|
2023-07-28 15:50:15 +02:00
|
|
|
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,
|
2023-11-28 19:48:10 +02:00
|
|
|
readme
|
|
|
|
.replace(
|
|
|
|
/https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g,
|
|
|
|
`https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`,
|
|
|
|
)
|
|
|
|
.replace(
|
|
|
|
/\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?!\()/g,
|
|
|
|
function (str, $0) {
|
|
|
|
const capital = $0.substr(0, 1);
|
|
|
|
const body = $0.substr(1).toLowerCase();
|
|
|
|
return `**${capital + body}**`;
|
|
|
|
},
|
|
|
|
),
|
2023-07-28 15:50:15 +02:00
|
|
|
);
|