1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-26 01:13:41 +02:00

Allow to use the function getThirdPartyExtensions at other locations (#7361)

This commit is contained in:
Álvaro Mondéjar 2022-04-30 09:04:46 -05:00 committed by GitHub
parent 98953e3463
commit 8f4e65ce28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View File

@ -128,14 +128,10 @@ export const normalizeNewlines = (text) => {
/**
* Get information about third party extensions.
* @param {String} readmePath Path to the README file
*/
export const getThirdPartyExtensions = async () => {
const __dirname = getDirnameFromImportMeta(import.meta.url);
const readmePath = path.resolve(__dirname, '..', 'README.md');
const readmeContent = normalizeNewlines(
await fs.readFile(readmePath, 'utf8'),
);
return readmeContent
export const getThirdPartyExtensions = async (readmePath) =>
normalizeNewlines(await fs.readFile(readmePath, 'utf8'))
.split('## Third-Party Extensions\n\n')[1]
.split('\n\n')[0]
.split('\n')
@ -153,4 +149,3 @@ export const getThirdPartyExtensions = async () => {
},
};
});
};

View File

@ -48,7 +48,8 @@ describe('README icons assets must be consistent with Github themes', () => {
});
test('README third party extensions must be alphabetically sorted', async () => {
const thirdPartyExtensions = await getThirdPartyExtensions();
const readmePath = path.join(root, 'README.md');
const thirdPartyExtensions = await getThirdPartyExtensions(readmePath);
assert.ok(thirdPartyExtensions.length > 0);
const thirdPartyExtensionsNames = thirdPartyExtensions.map(