mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 20:47:42 +01:00
* New setup for new NPM package * Add build scripts for dist * Add introduction readme * Refactor names * update package.json * remove log * rename variable * Factoring * Improve optimize script * Add eslint config * Eslint fixes * rename import * Move packeges * Setup rollup and build progress * Refactor scripts * fix lint error * remove lint disabler * Bring back old libraries * add indentation * reset packages directory * remove vscode setting files * 0.1.0-alpha.0 * new version * 0.1.0-alpha.1 * Fix build process * Add create element to the entry file * update version number * publish new alhpa version * fixing bugs * Add jest and tests * replace with XML createElement * set new version * Fix svg generation * Add tests for main library * Update docs * Adjust tests and selectors * update the spec * Update README.md * Update README.md * Update README.md * update version * Update README.md * Move function to helpers file * rename license, package and readme * Fix build files * rename packages Co-authored-by: Eric Fennis <eric.fennis@endurance.com>
75 lines
1.9 KiB
JavaScript
75 lines
1.9 KiB
JavaScript
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import { upperFirst, camelCase } from 'lodash/string';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* Generates a componentName of a String.
|
|
*
|
|
* @param {string} iconName
|
|
*/
|
|
export const generateComponentName = iconName =>
|
|
iconName === 'github' ? 'GitHub' : upperFirst(camelCase(iconName));
|
|
|
|
/**
|
|
* Resets the file contents.
|
|
*
|
|
* @param {string} fileName
|
|
* @param {string} outputDirectory
|
|
*/
|
|
export const resetFile = (fileName, outputDirectory) =>
|
|
fs.writeFileSync(path.join(outputDirectory, fileName), '', 'utf-8');
|
|
|
|
/**
|
|
* Reads the file contents.
|
|
*
|
|
* @param {string} path
|
|
*/
|
|
export const readFile = entry => fs.readFileSync(path.resolve(__dirname, '../', entry), 'utf-8');
|
|
|
|
/**
|
|
* append content to a file
|
|
*
|
|
* @param {string} content
|
|
* @param {string} fileName
|
|
* @param {string} outputDirectory
|
|
*/
|
|
export const appendFile = (content, fileName, outputDirectory) =>
|
|
fs.appendFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
|
|
|
/**
|
|
* writes content to a file
|
|
*
|
|
* @param {string} content
|
|
* @param {string} fileName
|
|
* @param {string} outputDirectory
|
|
*/
|
|
export const writeFile = (content, fileName, outputDirectory) =>
|
|
fs.writeFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
|
|
|
/**
|
|
* reads the icon directory
|
|
*
|
|
* @param {string} directory
|
|
*/
|
|
export const readSvgDirectory = directory =>
|
|
fs.readdirSync(directory).filter(file => path.extname(file) === '.svg');
|
|
|
|
/**
|
|
* Read svg from directory
|
|
*
|
|
* @param {string} fileName
|
|
* @param {string} directory
|
|
*/
|
|
export const readSvg = (fileName, directory) => fs.readFileSync(path.join(directory, fileName));
|
|
|
|
/**
|
|
* writes content to a file
|
|
*
|
|
* @param {string} fileName
|
|
* @param {string} outputDirectory
|
|
* @param {string} content
|
|
*/
|
|
export const writeSvgFile = (fileName, outputDirectory, content) =>
|
|
fs.appendFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|