mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-05-02 09:06:43 +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 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.
|
* Contains our tests so they can be isolated from each other.
|
||||||
@ -47,7 +47,7 @@ const TESTS = {
|
|||||||
|
|
||||||
/* Check the formatting of the data file */
|
/* Check the formatting of the data file */
|
||||||
prettified: async (data, dataString) => {
|
prettified: async (data, dataString) => {
|
||||||
const normalizedDataString = dataString.replace(/\r\n/g, '\n');
|
const normalizedDataString = normalizeNewlines(dataString);
|
||||||
const dataPretty = `${JSON.stringify(data, null, ' ')}\n`;
|
const dataPretty = `${JSON.stringify(data, null, ' ')}\n`;
|
||||||
|
|
||||||
if (normalizedDataString !== dataPretty) {
|
if (normalizedDataString !== dataPretty) {
|
||||||
|
@ -118,13 +118,23 @@ export const getIconsData = async () => {
|
|||||||
export const getDirnameFromImportMeta = (importMetaUrl) =>
|
export const getDirnameFromImportMeta = (importMetaUrl) =>
|
||||||
path.dirname(fileURLToPath(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.
|
* Get information about third party extensions.
|
||||||
*/
|
*/
|
||||||
export const getThirdPartyExtensions = async () => {
|
export const getThirdPartyExtensions = async () => {
|
||||||
const __dirname = getDirnameFromImportMeta(import.meta.url);
|
const __dirname = getDirnameFromImportMeta(import.meta.url);
|
||||||
const readmePath = path.resolve(__dirname, '..', 'README.md');
|
const readmePath = path.resolve(__dirname, '..', 'README.md');
|
||||||
const readmeContent = await fs.readFile(readmePath, 'utf8');
|
const readmeContent = normalizeNewlines(
|
||||||
|
await fs.readFile(readmePath, 'utf8'),
|
||||||
|
);
|
||||||
return readmeContent
|
return readmeContent
|
||||||
.split('## Third-Party Extensions\n\n')[1]
|
.split('## Third-Party Extensions\n\n')[1]
|
||||||
.split('\n\n')[0]
|
.split('\n\n')[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user