Files
lucide/scripts/build/helpers.js
T

38 lines
970 B
JavaScript
Raw Normal View History

2020-07-18 13:13:57 +02:00
import { upperFirst, camelCase } from 'lodash/string';
2020-07-18 00:52:09 +02:00
import fs from 'fs';
import path from 'path';
2020-07-17 23:07:51 +02:00
/**
* Generates a componentName of a String.
*
* @param {string} iconName
*/
2020-07-18 13:13:57 +02:00
export const generateComponentName = iconName =>
iconName === 'github' ? 'GitHub' : upperFirst(camelCase(iconName));
2020-07-18 00:52:09 +02:00
2020-07-18 12:39:08 +02:00
/**
* Resets the file contents.
*
* @param {string} fileName
* @param {string} outputDirectory
*/
2020-07-18 13:13:57 +02:00
export const resetFile = (fileName, outputDirectory) =>
fs.writeFileSync(path.join(outputDirectory, fileName), '', 'utf-8');
2020-07-18 00:52:09 +02:00
2020-08-18 21:31:10 +02:00
/**
* Reads the file contents.
*
* @param {string} path
*/
export const readFile = entry => fs.readFileSync(path.resolve(__dirname, '../../', entry), 'utf-8');
2020-07-18 12:39:08 +02:00
/**
* writes content to a file
*
* @param {string} content
* @param {string} fileName
* @param {string} outputDirectory
*/
2020-07-18 13:13:57 +02:00
export const writeFile = (content, fileName, outputDirectory) =>
fs.appendFileSync(path.join(outputDirectory, fileName), content, 'utf-8');