Skip to content

Commit

Permalink
Merge pull request #238 from api3dao/237-include-alternate-logos
Browse files Browse the repository at this point in the history
Refactor logo building script to use dynamic arrays
  • Loading branch information
hiletmis authored Feb 13, 2024
2 parents c33ba77 + 1764bd1 commit 34a61ae
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
22 changes: 2 additions & 20 deletions raw/chains/Chain11155420.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion raw/chains/Chain599.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 25 additions & 4 deletions scripts/build-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ const outputPath = './dist';

const categories = ['chain', 'symbol', 'api-provider'];

let chainLightLogos = [];
let apiProviderLightLogos = [];
let symbolLightLogos = [];

function getManualLogos(mode) {
switch (mode) {
case 'chain':
return ['5001-light', '5000-light', '280-light', '324-light', '59140-light', '59144-light'];
return [...chainLightLogos];
case 'symbol':
return [];
return [...symbolLightLogos];
case 'api-provider':
return [];
return [...apiProviderLightLogos];
default:
break;
}
Expand Down Expand Up @@ -133,10 +137,27 @@ async function renameFiles() {
});
}

async function findLightLogos() {
const [chainFiles, apiProviderFiles, symbolFiles] = await Promise.all([
fs.readdir('./optimized/chain', 'utf-8'),
fs.readdir('./optimized/api-provider', 'utf-8'),
fs.readdir('./optimized/symbol', 'utf-8')
]);

chainLightLogos = chainFiles
.filter((file) => file.includes('light'))
.map((file) => file.replace('Chain', ''))

apiProviderLightLogos = apiProviderFiles.filter((file) => file.includes('light'));

symbolLightLogos = symbolFiles.filter((file) => file.includes('light'));
}

async function main() {
console.log('🏗 Building logo package...');
rimraf(`${outputPath}/`)
.then(() => Promise.all([renameFiles()]))
.then(findLightLogos)
.then(renameFiles)
.then(() => Promise.all([generateLogos('cjs'), generateLogos('esm')]))
.then(() => console.log('✅ Finished building package.'));
}
Expand Down

0 comments on commit 34a61ae

Please sign in to comment.