diff --git a/bin/wappalyzer-validate-icons b/bin/wappalyzer-validate-icons index 3ec796ac6..185511826 100755 --- a/bin/wappalyzer-validate-icons +++ b/bin/wappalyzer-validate-icons @@ -12,43 +12,43 @@ var for (app in json.apps) { (function(app) { var basePath = process.env.WAPPALYZER_ROOT + '/src/icons/'; - var iconPath = json.apps[app].icon; - var path = basePath + iconPath; - - var type; - if (path.substr(path.length - 4) === '.png') { - type = "PNG"; - } - else if (path.substr(path.length - 4) === '.svg') { - type = "SVG"; - } - else { - var err = new Error('Icon file extension specified for app "' + app + '" is not ".png" or ".svg": src/icons/' + iconPath); - throw err; - } - + var iconPath = json.apps[app].icon || 'default.svg'; + var path = basePath + iconPath; + + var type; + if (path.substr(path.length - 4) === '.png') { + type = "PNG"; + } + else if (path.substr(path.length - 4) === '.svg') { + type = "SVG"; + } + else { + var err = new Error('Icon file extension specified for app "' + app + '" is not ".png" or ".svg": src/icons/' + iconPath); + throw err; + } + fs.exists(path, function(exists) { if (exists) { - if (type === "PNG") { - var buffer = fileType(readChunk.sync(path, 0, 262)); - if (buffer === null) { - var err = new Error('Unknown mimetype or bad file for "' + app + '": src/icons/' + iconPath); - throw err; - } - else if (buffer.mime !== 'image/png') { - var err = new Error('Incorrect mimetype "' + buffer.mime + '" when expected PNG for app "' + app + '": src/icons/' + iconPath); - throw err; - } - } - else if (type === "SVG") { - if (!isSvg(fs.readFileSync(path))) { - var err = new Error('Incorrect mimetype when expected SVG for app "' + app + '": src/icons/' + iconPath); - throw err; - } - } + if (type === "PNG") { + var buffer = fileType(readChunk.sync(path, 0, 262)); + if (buffer === null) { + var err = new Error('Unknown mimetype or bad file for "' + app + '": src/icons/' + iconPath); + throw err; + } + else if (buffer.mime !== 'image/png') { + var err = new Error('Incorrect mimetype "' + buffer.mime + '" when expected PNG for app "' + app + '": src/icons/' + iconPath); + throw err; + } + } + else if (type === "SVG") { + if (!isSvg(fs.readFileSync(path))) { + var err = new Error('Incorrect mimetype when expected SVG for app "' + app + '": src/icons/' + iconPath); + throw err; + } + } } else { var err = new Error('Missing file for app "' + app + '": src/icons/' + iconPath); - throw err; + throw err; } }); }(app)); diff --git a/schema.json b/schema.json index c70605b61..ac366218f 100644 --- a/schema.json +++ b/schema.json @@ -85,8 +85,7 @@ "required": true }, "icon": { - "type": "string", - "required": true + "type": "string" } } } diff --git a/src/apps.json b/src/apps.json index e8bf8fcb2..c1db523ff 100755 --- a/src/apps.json +++ b/src/apps.json @@ -865,7 +865,6 @@ "3" ], "html": "