From ece233ea8a0af3df652df98fdd42b14a1db03927 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Thu, 28 Sep 2017 18:42:48 -0400 Subject: [PATCH] Add support for scalable icons --- README.md | 4 ++- src/installer.js | 7 ++++- test/fixtures/icon.svg | 65 ++++++++++++++++++++++++++++++++++++++++++ test/installer.js | 3 +- 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/icon.svg diff --git a/README.md b/README.md index 093edf9..39047d9 100644 --- a/README.md +++ b/README.md @@ -357,10 +357,12 @@ Or multiple images with their corresponding resolutions: '48x48': 'resources/Icon48.png', '64x64': 'resources/Icon64.png', '128x128': 'resources/Icon128.png', - '256x256': 'resources/Icon256.png' + '256x256': 'resources/Icon256.png', + 'scalable': 'resources/Icon.svg' } } ``` +Note that the image files must be one of the types: PNG or SVG. The support for SVG works only on `scalable` resolution. #### options.categories Type: `Array[String]` diff --git a/src/installer.js b/src/installer.js index 2fd3a02..f95e30c 100644 --- a/src/installer.js +++ b/src/installer.js @@ -331,7 +331,12 @@ var createPixmapIcon = function (options, dir, callback) { */ var createHicolorIcon = function (options, dir, callback) { async.forEachOf(options.icon, function (icon, resolution, callback) { - var iconFile = path.join(dir, 'usr/share/icons/hicolor', resolution, 'apps', options.name + '.png') + var iconFile + if (resolution === 'scalable') { + iconFile = path.join(dir, 'usr/share/icons/hicolor', resolution, 'apps', options.name + '.svg') + } else { + iconFile = path.join(dir, 'usr/share/icons/hicolor', resolution, 'apps', options.name + '.png') + } options.logger('Creating icon file at ' + iconFile) mkdirp(path.dirname(iconFile), '0755', function (err, made) { diff --git a/test/fixtures/icon.svg b/test/fixtures/icon.svg new file mode 100644 index 0000000..4bb28b1 --- /dev/null +++ b/test/fixtures/icon.svg @@ -0,0 +1,65 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/test/installer.js b/test/installer.js index 58c385a..7575709 100644 --- a/test/installer.js +++ b/test/installer.js @@ -56,7 +56,8 @@ describe('module', function () { options: { icon: { - '1024x1024': 'test/fixtures/icon.png' + '1024x1024': 'test/fixtures/icon.png', + 'scalable': 'test/fixtures/icon.svg' }, bin: 'resources/cli/bar.sh', productDescription: 'Just a test.',