Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions generate-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require('path');
// The generated components are based on the Bootstrap Icons URL, for example: https://icons.getbootstrap.com/icons/alarm-fill/
// If the URL changes, then the components will not be generated correctly
const iconsUrl = 'https://icons.getbootstrap.com/';
const iconsPath = './icons/';
let iconsPath = './icons/';

function toPascalCase(str) {
return str
Expand Down Expand Up @@ -75,14 +75,23 @@ async function generateIconComponent(icon) {
const component = ejs.render(template, { iconName: iconComponentName, width: 16, height: 16, paths });

// Write the component to a file
console.log(`Generating ${iconComponentName}...`);
console.log(`Generating ${iconComponentName}...`);
fs.writeFileSync(path.join(iconsPath, `${iconComponentName}.tsx`), component);
}

async function generateIcons() {
const argIconNames = process.argv.slice(2);
const icons = await fetchIconsList(argIconNames);

if (argIconNames.some(arg => arg.startsWith('--path='))) {
const strPathIndex = argIconNames.findIndex(arg => arg.startsWith('--path='));
const strPath = argIconNames[strPathIndex].substring('--path='.length);
const match = strPath.match(/(.+)/);
if (match) {
iconsPath = match[1];
}
}

// If the iconsPath does not exist, then create it
if (!fs.existsSync(iconsPath)) {
fs.mkdirSync(iconsPath);
Expand Down