Files
lucide/packages/lucide-static/scripts/readSvgs.mts
Eric Fennis 3e644fda2d chore(scripts): Refactor scripts to typescript (#3316)
* Adjust typescript types

* adjust types

* fix types in all helper files

* Fix types

* Migrate js files to ts files

* Refactor to TS files

* Rename extentions

* Adjust imports

* Fix builds

* Update lockfile

* Fix last typescript migration

* Fix entry path @lucide/outline-svg

* Fix types

* add checkout step

* format files

* Format files
2025-06-18 15:47:24 +02:00

32 lines
883 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
}