Properly fail if icon is not found by pageicon

This commit is contained in:
Jia Hao 2016-03-10 15:52:02 +08:00
parent 34a5a52a28
commit d04cf0ad3a
1 changed files with 3 additions and 0 deletions

View File

@ -19,6 +19,9 @@ function inferIconFromUrlToPath(targetUrl, platform, outDir, callback) {
pageIcon(targetUrl, {ext: preferredExt})
.then(icon => {
if (!icon) {
throw 'Icon not found';
}
const outfilePath = path.join(outDir, `/icon.${icon.ext}`);
fs.writeFile(outfilePath, icon.data, error => {
callback(error, outfilePath);