mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-17 02:17:42 +01:00
* init svelte project * Add export script for lucide-svelte * make lucide-svelte wokring * make ready for first release * update lock file * bump version * some fixes in the build * Add tests * Finish tests * Update Readme * update lock file * Add svelte to gh actions * Add svetle to website docs * Add test ci script * adjust action * add on PR trigger * remove dep * fix tests * Add svelte entry in package.json * update snapshots
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import getArgumentOptions from 'minimist'; // eslint-disable-line import/no-extraneous-dependencies
|
|
|
|
import renderIconsObject from './render/renderIconsObject';
|
|
import generateIconFiles from './build/generateIconFiles';
|
|
import generateExportsFile from './build/generateExportsFile';
|
|
|
|
import { readSvgDirectory } from './helpers';
|
|
|
|
const cliArguments = getArgumentOptions(process.argv.slice(2));
|
|
|
|
const ICONS_DIR = path.resolve(__dirname, '../icons');
|
|
const OUTPUT_DIR = path.resolve(__dirname, cliArguments.output || '../build');
|
|
|
|
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
fs.mkdirSync(OUTPUT_DIR);
|
|
}
|
|
|
|
const {
|
|
renderUniqueKey = false,
|
|
templateSrc = './templates/defaultIconFileTemplate',
|
|
silent = false,
|
|
iconFileExtention = '.js',
|
|
exportFileName = 'index.js',
|
|
pretty = true,
|
|
} = cliArguments;
|
|
|
|
const svgFiles = readSvgDirectory(ICONS_DIR);
|
|
|
|
const icons = renderIconsObject(svgFiles, ICONS_DIR, renderUniqueKey);
|
|
|
|
// eslint-disable-next-line import/no-dynamic-require
|
|
const iconFileTemplate = require(templateSrc).default;
|
|
|
|
// Generates iconsNodes files for each icon
|
|
generateIconFiles({
|
|
iconNodes: icons,
|
|
outputDirectory: OUTPUT_DIR,
|
|
template: iconFileTemplate,
|
|
showLog: !silent,
|
|
iconFileExtention,
|
|
pretty: JSON.parse(pretty),
|
|
});
|
|
|
|
// Generates entry files for the compiler filled with icons exports
|
|
generateExportsFile(
|
|
path.join(OUTPUT_DIR, 'icons', exportFileName),
|
|
path.join(OUTPUT_DIR, 'icons'),
|
|
icons,
|
|
iconFileExtention,
|
|
);
|