forked from MyEtherWallet/ethereum-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkLogos.js
31 lines (25 loc) · 864 Bytes
/
checkLogos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const tokensDirectory = './src/tokens';
const request = require('request');
function checkTokenLogos() {
let invalidImgArray = [];
fs.readdirSync(tokensDirectory).forEach(folder => {
fs.readdirSync(`${tokensDirectory}/${folder}`).forEach(file => {
const fullPath = `${tokensDirectory}/${folder}/${file}`;
const obj = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
if (obj.logo.src === '') {
return;
}
request({method: 'HEAD', uri: obj.logo.src}, function(err, response) {
if (err) {
invalidImgArray.push(obj.logo.src);
}
if (!err && response.statusCode === 400) {
invalidImgArray.push(obj.logo.src);
}
fs.writeFileSync('./invalidLogoSrc.js', JSON.stringify(invalidImgArray))
})
})
})
}
checkTokenLogos();