Files
lucide/packages/lucide-static/scripts/readSvgs.mjs
Eric Fennis 50630b3aaf ci: Improve build speeds (#2778)
* Revert sync to async functions

* Replace more sync fs functions

* Format files

* Fix build svelte package
2025-02-10 14:13:52 +01:00

21 lines
680 B
JavaScript

/* eslint-disable import/no-extraneous-dependencies */
import { basename } from 'path';
import { readSvg } from '@lucide/helpers';
/**
* 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, iconsDirectory) {
const SVGReadPromises = svgFiles.map(async (svgFile) => {
const name = basename(svgFile, '.svg');
const contents = await readSvg(svgFile, iconsDirectory);
return { name, contents };
});
return Promise.all(SVGReadPromises);
}