Skip to content

Commit

Permalink
fix: build icon
Browse files Browse the repository at this point in the history
  • Loading branch information
darrytai committed May 21, 2024
1 parent cf13d41 commit 15d98c3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions script/build-icon-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ const svgPathEnd = '"></path>';
const dataFromSvgFile = {};
const dataParsedFromApi = {};
const svgFolder = path.resolve(__dirname, '../dist/svg');

const preferences = require('../data/Preferences.json');
const iconsData = require('../data/Icons.json');
const iconsetsData = require('../data/Iconsets.json');
const preferencesDataPath = path.resolve(__dirname, '../data/Preferences.json');
const IconsDataPath = path.resolve(__dirname, '../data/Icons.json');
const outputIndexPath = path.resolve(__dirname, '../src/icons/index.js');
const outputIconsFolder = path.resolve(__dirname, '../src/icons');
const outputIconsetsPath = path.resolve(__dirname, '../src/iconsets/index.js');
Expand Down Expand Up @@ -56,15 +54,17 @@ fs.readdirSync(svgFolder).forEach(file => {
dataFromSvgFile[file.split('.svg')[0].toLowerCase()] = { paths, viewBox };
});

// console.log(dataFromSvgFile);
if (count > 0) {
console.log('Incorrect viewBox count', count);
}

const _majorVersion = preferences.fontPref.metadata.majorVersion;
const _minorVersion = preferences.fontPref.metadata.minorVersion;

const reference = fs.readFileSync(preferencesDataPath, 'utf-8');
const referenceData = JSON.parse(reference);
const _majorVersion = referenceData.fontPref.metadata.majorVersion;
const _minorVersion = referenceData.fontPref.metadata.minorVersion;

const icons = fs.readFileSync(IconsDataPath, 'utf-8');
const iconsData = JSON.parse(icons);
dataParsedFromApi.icons = iconsData
.sort(function(a, b) {
var nameA = a.name.toLowerCase() // ignore upper and lowercase
Expand Down Expand Up @@ -129,7 +129,7 @@ dataParsedFromApi.icons = iconsData
}

{ // iconsets
const iconsets = _sortBy(iconsetsData, ['id']);
const iconsets = _sortBy(require('../data/Iconsets.json'), ['id']);
const ejsTemplate = [
'// AUTO-GENERATED FILE. DO NOT MODIFY.',
'',
Expand Down

0 comments on commit 15d98c3

Please sign in to comment.