simple-icons/tests/readme-icons.test.js
Alexandre Paradis a253682eb8
Add some icons in Readme (#4816)
* Add some icons in Readme

* Align icons at left

* Add some more icons

* Remove inline image

- Use relative icons path

* Format Third Party Extensions
 as a table

* force website build

* added readme-icons foler with icons for the readme.md file, as well as icons for light and dark modes in the readme.md titles

* restored corrupted svgs for readme-icons

* moved the icons to asset/readme, added icons for Drawio, Hexo and Jetpack Compose

* - Use `develop` branch absolutified links for README images
- Strip dark image theme links before publish to Github and npm
- Clean third party extensions table

* Commit to tag (ony inside master branch)

* Fix differences in README

* Reintroduce link in README logo

* Drop uneeded newline from README

* Fix error in README

* Add newlines for SVGs

* Newlines for all SVGs

* Reuse black icons from library

* Commit using Github Actions bot

* Reuse diagrams.net library icon for white version

* Fix comment

* Bump 'strip-gh-theme-links' action to v2

* removed assets/readme icons

* Test with 'fill=white'

* Test with 'style="fill:white"'

* added filter:invert(1) to PHP, TS, Simple Icons and Blender

* added readme-icons test, changed the name of light icons in assets/readme

* reloaded icons in Readme

* fixed typo in iconsPath for readme-icons test

* fixed typo on the darkiconsPath resolution

* restored absolute paths

* minimized the white icons on assets/readme

* restored test scripts

* Apply changes

* Disable color output testing in CI

* Revert latest change

Co-authored-by: Eric Cornelissen <ericornelissen@gmail.com>
Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
Co-authored-by: Jorge Amado Soria Ramirez <darksoul.uci@gmail.com>
2022-01-09 15:04:36 -06:00

35 lines
1.2 KiB
JavaScript

import { promises as fs } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { test, exec } from 'uvu';
import * as assert from 'uvu/assert';
(async () => {
const __dirname = path.dirname(fileURLToPath(import.meta.url)),
root = path.dirname(__dirname),
darkIconsPath = path.join(root, 'icons'),
lightIconsPath = path.join(root, 'assets', 'readme'),
lightIconsFileNames = await fs.readdir(lightIconsPath);
for (let lightIconFileName of lightIconsFileNames) {
const lightIconPath = path.join(lightIconsPath, lightIconFileName),
darkIconPath = path.join(
darkIconsPath,
lightIconFileName.replace(/-white\.svg$/, '.svg'),
),
lightIconRelPath = path.relative(root, lightIconPath),
darkIconRelPath = path.relative(root, darkIconPath),
lightIconContent = await fs.readFile(lightIconPath, 'utf8'),
darkIconContent = await fs.readFile(darkIconPath, 'utf8');
test(`'${lightIconRelPath}' content must be equivalent to '${darkIconRelPath}' content`, () => {
assert.equal(
lightIconContent.replace(' fill="white"', ''),
darkIconContent,
);
});
}
test.run();
exec();
})();