mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-15 14:08:49 +00:00
fix(build-icons): support Windows paths in dynamic imports for template and metadata (#5058)
Co-authored-by: grzdev <grzdev@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { pathToFileURL } from 'url';
|
||||
import getArgumentOptions from 'minimist';
|
||||
|
||||
import { readSvgDirectory } from '@lucide/helpers';
|
||||
@@ -76,7 +77,9 @@ async function buildIcons() {
|
||||
|
||||
const icons = await renderIconsObject(svgFiles, ICONS_DIR, renderUniqueKey);
|
||||
|
||||
const { default: iconFileTemplate } = await import(path.resolve(process.cwd(), templateSrc));
|
||||
const { default: iconFileTemplate } = await import(
|
||||
pathToFileURL(path.resolve(process.cwd(), templateSrc)).href
|
||||
);
|
||||
|
||||
const iconMetaData = await getIconMetaData(ICONS_DIR);
|
||||
|
||||
@@ -135,4 +138,5 @@ try {
|
||||
await buildIcons();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'path';
|
||||
import { pathToFileURL } from 'url';
|
||||
import { readSvgDirectory } from '@lucide/helpers';
|
||||
import { type IconMetadata } from '../types.ts';
|
||||
|
||||
@@ -7,7 +8,9 @@ async function getIconMetaData(iconDirectory: string): Promise<Record<string, Ic
|
||||
const aliasesEntries = await Promise.all(
|
||||
iconJsons.map(async (jsonFile: string) => {
|
||||
/** eslint-disable */
|
||||
const file = await import(path.join(iconDirectory, jsonFile), { with: { type: 'json' } });
|
||||
const file = await import(pathToFileURL(path.join(iconDirectory, jsonFile)).href, {
|
||||
with: { type: 'json' },
|
||||
});
|
||||
return [path.basename(jsonFile, '.json'), file.default];
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user