Files
lucide/packages/lab/scripts/readSvgs.mts
Eric Fennis 1502285072 fix(@lucide/lab): Fix lab build (#4618)
* chore(lab): Adjust build scripts

* add check workflow

* Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* update gitignore

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-07-31 09:11:20 +02:00

32 lines
885 B
TypeScript

/* eslint-disable import/no-extraneous-dependencies */
import { basename } from 'path';
import { readSvg } from '@lucide/helpers';
import { type INode, parseSync } from 'svgson';
/**
* Build an object in the format: `{ <name>: <contents> }`.
* @param {string[]} svgFiles - A list of filenames.
* @param {Function} getSvg - A function that returns the contents of an SVG file given a filename.
* @returns {Object}
*/
export default function readSVGs(svgFiles: string[], iconsDirectory: string) {
const SVGReadPromises = svgFiles.map(async (svgFile) => {
const name = basename(svgFile, '.svg');
const contents = await readSvg(svgFile, iconsDirectory);
return {
name,
contents,
parsedSvg: parseSync(contents),
};
});
return Promise.all(SVGReadPromises);
}
export type SVGFile = {
name: string;
contents: string;
parsedSvg: INode;
};