Skip to content

Commit

Permalink
Version 1.0.2 fix download icon contains space
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebouttier committed Jul 13, 2021
1 parent 380a081 commit 9d01537
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ if (!_.isEmpty(config.apikey)) {
.then(() => {
const cryptosData = _.filter(
cryptos,
(o) => !_.includes(filesIconsExists, o) && !_.includes(blacklist, o)
(o) =>
!_.includes(filesIconsExists, o.replace(/\s+/g, '')) &&
!_.includes(blacklist, o.replace(/\s+/g, ''))
);

cmlog.success(`Retrieving the list of cryptos Total: [${cryptosData.length}]`);
Expand All @@ -55,7 +57,11 @@ if (!_.isEmpty(config.apikey)) {
cmlog.done('All icons have been updated !');
} else {
cryptosData.forEach((crypto, index) => {
const cryptoName = crypto.replace(/\s+/g, '');
let cryptoName = crypto;

if (cryptoName.indexOf(' ') >= 0) {
cryptoName = crypto.replace(/\s+/g, '');
}

setTimeout(() => {
axios
Expand All @@ -66,7 +72,7 @@ if (!_.isEmpty(config.apikey)) {
}
)
.then((o) => {
const imageUrl = o.data.data[_.upperCase(cryptoName)].logo;
const imageUrl = _.values(o.data.data)[0].logo;
const options = {
url: imageUrl,
dest: `${folderPatch}/icons/${cryptoName}.png`
Expand All @@ -75,12 +81,13 @@ if (!_.isEmpty(config.apikey)) {
download
.image(options)
.then(({ filename }) => {
cmlog.success(`Icon saved ${filename}`);
cmlog.success(`Icon saved ${cryptoName} => ${filename}`);
cmlog.waitting(`PROGRESS [${index + 1}/${cryptosData.length}]`);
})
.catch((err) => cmlog.error(new Error(err)));
})
.catch((err) => {
cmlog.error(new Error(`Error => "${cryptoName} ${err}"`));
if (err && err.response && err.response.status === 400) {
cmlog.error(new Error(`Crypto icon not found => "${cryptoName}"`));

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coinmarketcap-icons-cryptos",
"version": "1.0.1",
"version": "1.0.2",
"description": "Get all images icons cryptos coinmarketcap",
"main": "app.js",
"repository": "https://github.com/alexandrebouttier/coinmarketcap-icons-cryptos.git",
Expand Down

0 comments on commit 9d01537

Please sign in to comment.