From a8072d2234ff7695612c948fc998b2f5b7ef4454 Mon Sep 17 00:00:00 2001 From: Jia Hao Date: Mon, 14 Mar 2016 12:28:14 +0800 Subject: [PATCH] Hopefully fix icon retrieval bugs Icon ext from page-icon contains `.` before ext now, e.g. `.png` --- package.json | 2 +- src/helpers/helpers.js | 6 +++--- src/infer/inferIcon.js | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 878c589..5b9fe9a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "hasbin": "^1.2.0", "lodash": "^4.0.0", "ncp": "^2.0.0", - "page-icon": "^0.2.0", + "page-icon": "^0.3.0", "progress": "^1.1.8", "request": "^2.67.0", "sanitize-filename": "^1.5.3", diff --git a/src/helpers/helpers.js b/src/helpers/helpers.js index e96f2d7..f0bc904 100644 --- a/src/helpers/helpers.js +++ b/src/helpers/helpers.js @@ -53,7 +53,7 @@ function allowedIconFormats(platform) { formats.push('.png'); break; case 'win32': - formats.push('ico'); + formats.push('.ico'); break; default: throw `function allowedIconFormats error: Unknown platform ${platform}`; @@ -77,7 +77,7 @@ function allowedIconFormats(platform) { formats.push('.ico'); } if (icnsToPng) { - formats.push('icns'); + formats.push('.icns'); } break; case 'win32': @@ -86,7 +86,7 @@ function allowedIconFormats(platform) { formats.push('.png'); } if (icnsToIco) { - formats.push('icns'); + formats.push('.icns'); } break; default: diff --git a/src/infer/inferIcon.js b/src/infer/inferIcon.js index 9e66f75..cb88f09 100644 --- a/src/infer/inferIcon.js +++ b/src/infer/inferIcon.js @@ -55,9 +55,9 @@ function writeFilePromise(outPath, data) { } function inferFromPage(targetUrl, platform, outDir) { - let preferredExt = 'png'; + let preferredExt = '.png'; if (platform === 'win32') { - preferredExt = 'ico'; + preferredExt = '.ico'; } // todo might want to pass list of preferences instead @@ -67,8 +67,7 @@ function inferFromPage(targetUrl, platform, outDir) { return null; } - // note that ext from page icon does not contain a '.' - const outfilePath = path.join(outDir, `/icon.${icon.ext}`); + const outfilePath = path.join(outDir, `/icon${icon.ext}`); return writeFilePromise(outfilePath, icon.data); }); }