2021-11-21 20:27:15 +01:00
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
|
|
|
import { basename } from 'path';
|
2022-08-10 09:10:53 +02:00
|
|
|
import { readSvg } from '../../../scripts/helpers.mjs';
|
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) {
|
|
|
|
|
return svgFiles.map((svgFile) => {
|
2021-11-21 20:27:15 +01:00
|
|
|
const name = basename(svgFile, '.svg');
|
|
|
|
|
const contents = readSvg(svgFile, iconsDirectory);
|
|
|
|
|
|
|
|
|
|
return { name, contents };
|
|
|
|
|
});
|
2023-11-17 11:12:31 +01:00
|
|
|
}
|