Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Oct 3, 2024
1 parent 0438af4 commit 5421f0f
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env node
/* eslint-disable import/no-commonjs, import/no-nodejs-modules, import/no-nodejs-modules, no-console */
const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';

const ASSETS_FOLDER = 'assets';
const GENERATED_ASSETS_FILE = 'Icon.assets.ts';
const TYPES_FILE = 'Icon.types.ts';
const ASSET_EXT = '.svg';
const TYPES_CONTENT_TO_DETECT = '// DO NOT EDIT - Use generate-assets.js';

const getIconNameInTitleCase = (fileName: string): string =>
const getIconNameInTitleCase = (fileName: string) =>
path
.basename(fileName, ASSET_EXT)
.split('-')
.map(
(section: string) =>
(section) =>
`${section[0].toUpperCase()}${section.substring(1, section.length)}`,
)
.join('');
Expand All @@ -26,11 +26,11 @@ const main = async () => {

const fileList = fs.readdirSync(assetsFolderPath);
const assetFileList = fileList.filter(
(fileName: string): fileName is string => path.extname(fileName) === ASSET_EXT,
(fileName) => path.extname(fileName) === ASSET_EXT,
);

// Replace the color black with currentColor
assetFileList.forEach((fileName: string) => {
assetFileList.forEach((fileName) => {
const filePath = path.join(__dirname, `../${ASSETS_FOLDER}/${fileName}`);
const fileContent = fs.readFileSync(filePath, { encoding: 'utf-8' });
const formattedFileContent = fileContent.replace(/black/g, 'currentColor');
Expand All @@ -53,7 +53,7 @@ const main = async () => {
`\nimport { AssetByIconName, IconName } from './Icon.types';`,
);

assetFileList.forEach((fileName: string) => {
assetFileList.forEach((fileName) => {
const iconName = getIconNameInTitleCase(fileName).toLowerCase();
fs.appendFileSync(
assetsModulePath,
Expand All @@ -71,7 +71,7 @@ const main = async () => {
`\nexport const assetByIconName: AssetByIconName = {`,
);

assetFileList.forEach(async (fileName: string) => {
assetFileList.forEach(async (fileName) => {
const iconName = getIconNameInTitleCase(fileName);
fs.appendFileSync(
assetsModulePath,
Expand All @@ -95,12 +95,12 @@ const main = async () => {

typesContentToWrite += '\n\n/**\n * Icon names\n */\nexport enum IconName {';

assetFileList.forEach((fileName: string) => {
assetFileList.forEach((fileName) => {
const iconName = path
.basename(fileName, ASSET_EXT)
.split('-')
.map(
(section: string) =>
(section) =>
`${section[0].toUpperCase()}${section.substring(1, section.length)}`,
)
.join('');
Expand Down

0 comments on commit 5421f0f

Please sign in to comment.