mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 09:54:11 +03:00
Normalize newline characters reading README in scripts (#7292)
This commit is contained in:
parent
38cc1af542
commit
44064880b4
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import fakeDiff from 'fake-diff';
|
||||
import { getIconsDataString } from '../utils.js';
|
||||
import { getIconsDataString, normalizeNewlines } from '../utils.js';
|
||||
|
||||
/**
|
||||
* Contains our tests so they can be isolated from each other.
|
||||
@ -47,7 +47,7 @@ const TESTS = {
|
||||
|
||||
/* Check the formatting of the data file */
|
||||
prettified: async (data, dataString) => {
|
||||
const normalizedDataString = dataString.replace(/\r\n/g, '\n');
|
||||
const normalizedDataString = normalizeNewlines(dataString);
|
||||
const dataPretty = `${JSON.stringify(data, null, ' ')}\n`;
|
||||
|
||||
if (normalizedDataString !== dataPretty) {
|
||||
|
@ -118,13 +118,23 @@ export const getIconsData = async () => {
|
||||
export const getDirnameFromImportMeta = (importMetaUrl) =>
|
||||
path.dirname(fileURLToPath(importMetaUrl));
|
||||
|
||||
/**
|
||||
* Replace Windows newline characters by Unix ones.
|
||||
* @param {String} text The text to replace
|
||||
*/
|
||||
export const normalizeNewlines = (text) => {
|
||||
return text.replace(/\r\n/g, '\n');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get information about third party extensions.
|
||||
*/
|
||||
export const getThirdPartyExtensions = async () => {
|
||||
const __dirname = getDirnameFromImportMeta(import.meta.url);
|
||||
const readmePath = path.resolve(__dirname, '..', 'README.md');
|
||||
const readmeContent = await fs.readFile(readmePath, 'utf8');
|
||||
const readmeContent = normalizeNewlines(
|
||||
await fs.readFile(readmePath, 'utf8'),
|
||||
);
|
||||
return readmeContent
|
||||
.split('## Third-Party Extensions\n\n')[1]
|
||||
.split('\n\n')[0]
|
||||
|
Loading…
Reference in New Issue
Block a user