mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
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
This commit is contained in:
@@ -8,7 +8,7 @@ import DEFAULT_ATTRS from '../../tools/build-icons/render/default-attrs.json' wi
|
||||
* @param {string} svg - An SVG string.
|
||||
* @returns {Promise<string>} An optimized svg
|
||||
*/
|
||||
async function optimizeSvg(svg, path) {
|
||||
async function optimizeSvg(svg: string, path: string) {
|
||||
const result = optimize(svg, {
|
||||
path,
|
||||
plugins: [
|
||||
@@ -38,10 +38,16 @@ async function optimizeSvg(svg, path) {
|
||||
* @param {string} svg - An SVG string.
|
||||
* @returns {string} An SVG string, included with the default attributes.
|
||||
*/
|
||||
function setAttrs(svg) {
|
||||
function setAttrs(svg: string) {
|
||||
const contents = parseSync(svg);
|
||||
|
||||
contents.attributes = DEFAULT_ATTRS;
|
||||
contents.attributes = {
|
||||
...DEFAULT_ATTRS,
|
||||
width: String(DEFAULT_ATTRS.width),
|
||||
height: String(DEFAULT_ATTRS.height),
|
||||
"stroke-width": String(DEFAULT_ATTRS['stroke-width']),
|
||||
...contents.attributes,
|
||||
};
|
||||
|
||||
return stringify(contents);
|
||||
}
|
||||
@@ -51,7 +57,7 @@ function setAttrs(svg) {
|
||||
* @param {string} svg An SVG string.
|
||||
* @returns {Promise<string>} An optimized svg
|
||||
*/
|
||||
function processSvg(svg, path) {
|
||||
function processSvg(svg: string, path: string) {
|
||||
return (
|
||||
optimizeSvg(svg, path)
|
||||
.then(setAttrs)
|
||||
Reference in New Issue
Block a user