diff --git a/scripts/utils.js b/scripts/utils.js index 1193310af..194dc2eca 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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 () => { }, }; }); -}; diff --git a/tests/readme.test.js b/tests/readme.test.js index 8ba82f551..0f95718bf 100644 --- a/tests/readme.test.js +++ b/tests/readme.test.js @@ -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(