2021-11-21 20:27:15 +01:00
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
|
|
|
import { basename } from 'path';
|
2024-06-28 11:24:37 +02:00
|
|
|
import { readSvg } from '@lucide/helpers';
|
2021-11-21 20:27:15 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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}
|
|
|
|
|
*/
|
2023-11-17 11:12:31 +01:00
|
|
|
export default function readSVGs(svgFiles, iconsDirectory) {
|
2025-02-10 14:13:52 +01:00
|
|
|
const SVGReadPromises = svgFiles.map(async (svgFile) => {
|
2021-11-21 20:27:15 +01:00
|
|
|
const name = basename(svgFile, '.svg');
|
2025-02-10 14:13:52 +01:00
|
|
|
const contents = await readSvg(svgFile, iconsDirectory);
|
2021-11-21 20:27:15 +01:00
|
|
|
|
|
|
|
|
return { name, contents };
|
|
|
|
|
});
|
2025-02-10 14:13:52 +01:00
|
|
|
|
|
|
|
|
return Promise.all(SVGReadPromises);
|
2023-11-17 11:12:31 +01:00
|
|
|
}
|