forked from simple-icons/simple-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize disclaimer formatting (simple-icons#10439)
- Loading branch information
Showing
4 changed files
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @fileoverview | ||
* Rewrite some Markdown files. | ||
*/ | ||
|
||
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 disclaimerFile = path.resolve(rootDir, 'DISCLAIMER.md'); | ||
|
||
const reformat = async (filePath) => { | ||
const fileContent = await readFile(filePath, 'utf8'); | ||
await writeFile( | ||
filePath, | ||
fileContent | ||
// Replace all CDN links with raw links | ||
.replace( | ||
/https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g, | ||
`https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`, | ||
) | ||
// Replace all GitHub blockquotes with regular markdown | ||
// Reference: https://github.com/orgs/community/discussions/16925 | ||
.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}**`; | ||
}, | ||
), | ||
); | ||
}; | ||
|
||
await Promise.all([reformat(readmeFile), reformat(disclaimerFile)]); |
This file was deleted.
Oops, something went wrong.