mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-12 13:38:32 +00:00
* cleanup scripts * Move helpers to package * Fixes scripts * Fix scripts * Formatting * Fix helpers import paths * Remove lucide-figma * Rename helpers package * Fix build * formatting * Adjust main build-icons file * Add export casing * Adds `exportModuleNameCasing` fro lab project * format files * Bump package version @lucide/build-icons * Revert changes in icons * Revert changes in PR yml * Fix lint issues * Fix site build * fix lint errors * Attempt fix linting * Fix lint errors
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import getArgumentOptions from 'minimist';
|
|
import { parseSync } from 'svgson';
|
|
|
|
import { readSvgDirectory, getCurrentDirPath } from '@lucide/helpers';
|
|
import readSvgs from './readSvgs.mjs';
|
|
import generateSprite from './generateSprite.mjs';
|
|
import generateIconNodes from './generateIconNodes.mjs';
|
|
import copyIcons from './copyIcons.mjs';
|
|
|
|
import pkg from '../package.json' with { type: 'json' };
|
|
|
|
const cliArguments = getArgumentOptions(process.argv.slice(2));
|
|
const createDirectory = (dir) => {
|
|
if (!fs.existsSync(dir)) {
|
|
fs.mkdirSync(dir);
|
|
}
|
|
};
|
|
|
|
const currentDir = getCurrentDirPath(import.meta.url);
|
|
|
|
const PACKAGE_DIR = path.resolve(currentDir, '../');
|
|
const ICONS_DIR = path.join(PACKAGE_DIR, '../../icons');
|
|
const LIB_DIR = path.join(PACKAGE_DIR, cliArguments.output || 'lib');
|
|
const ICON_MODULE_DIR = path.join(LIB_DIR, 'icons');
|
|
|
|
const license = `@license ${pkg.name} v${pkg.version} - ${pkg.license}`;
|
|
|
|
createDirectory(LIB_DIR);
|
|
createDirectory(ICON_MODULE_DIR);
|
|
|
|
const svgFiles = readSvgDirectory(ICONS_DIR);
|
|
const svgs = readSvgs(svgFiles, ICONS_DIR);
|
|
|
|
const parsedSvgs = svgs.map(({ name, contents }) => ({
|
|
name,
|
|
contents,
|
|
parsedSvg: parseSync(contents),
|
|
}));
|
|
|
|
generateSprite(parsedSvgs, PACKAGE_DIR, license);
|
|
generateIconNodes(parsedSvgs, PACKAGE_DIR);
|
|
copyIcons(parsedSvgs, PACKAGE_DIR, license);
|