Skip to content

Commit c6b1f6b

Browse files
author
Caffa
committed
Implemented Windows and Linux support
1 parent eb12a11 commit c6b1f6b

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ That's it. Now every time you ```cordova build```, the icons will be auto genera
4343
Install on a Mac:
4444

4545
$ brew install imagemagick
46+
47+
Install on Linux:
48+
49+
$ sudo apt-get install imagemagick
4650

4751
On windows see http://www.imagemagick.org/script/binary-releases.php#windows
4852

index.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var ig = require('imagemagick');
44
var colors = require('colors');
55
var _ = require('underscore');
66
var Q = require('q');
7+
var path = require('path');
78

89
/**
910
* Check which platforms are added to the project and return their icon names and sized
@@ -12,13 +13,14 @@ var Q = require('q');
1213
* @return {Promise} resolves with an array of platforms
1314
*/
1415
var getPlatforms = function (projectName) {
16+
projectName = projectName ? projectName : '';
1517
var deferred = Q.defer();
1618
var platforms = [];
1719
platforms.push({
1820
name : 'ios',
1921
// TODO: use async fs.exists
20-
isAdded : fs.existsSync('platforms/ios'),
21-
iconsPath : 'platforms/ios/' + projectName + '/Resources/icons/',
22+
isAdded : fs.existsSync(path.resolve('platforms', 'ios')),
23+
iconsPath : path.resolve('platforms', 'ios', projectName, 'Resources', 'icons'),
2224
icons : [
2325
{ name : 'icon-40.png', size : 40 },
2426
{ name : 'icon-40@2x.png', size : 80 },
@@ -39,15 +41,15 @@ var getPlatforms = function (projectName) {
3941
});
4042
platforms.push({
4143
name : 'android',
42-
iconsPath : 'platforms/android/res/',
43-
isAdded : fs.existsSync('platforms/android'),
44+
iconsPath : path.resolve('platforms', 'android', 'res'),
45+
isAdded : fs.existsSync(path.resolve('platforms', 'android')),
4446
icons : [
45-
{ name : 'drawable/icon.png', size : 96 },
46-
{ name : 'drawable-hdpi/icon.png', size : 72 },
47-
{ name : 'drawable-ldpi/icon.png', size : 36 },
48-
{ name : 'drawable-mdpi/icon.png', size : 48 },
49-
{ name : 'drawable-xhdpi/icon.png', size : 96 },
50-
{ name : 'drawable-xxhdpi/icon.png', size : 144 },
47+
{ name : path.join('drawable', 'icon.png'), size : 96 },
48+
{ name : path.join('drawable-hdpi', 'icon.png'), size : 72 },
49+
{ name : path.join('drawable-ldpi', 'icon.png'), size : 36 },
50+
{ name : path.join('drawable-mdpi', 'icon.png'), size : 48 },
51+
{ name : path.join('drawable-xhdpi', 'icon.png'), size : 96 },
52+
{ name : path.join('drawable-xxhdpi', 'icon.png'), size : 144 },
5153
]
5254
});
5355
// TODO: add all platforms
@@ -114,9 +116,10 @@ var getProjectName = function () {
114116
*/
115117
var generateIcon = function (platform, icon) {
116118
var deferred = Q.defer();
119+
117120
ig.resize({
118121
srcPath: settings.ICON_FILE,
119-
dstPath: platform.iconsPath + icon.name,
122+
dstPath: path.resolve(platform.iconsPath, icon.name),
120123
quality: 1,
121124
format: 'png',
122125
width: icon.size,

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-icon",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Automatic icon resizing for Cordova",
55
"main": "index.js",
66
"preferGlobal": "true",
@@ -12,19 +12,19 @@
1212
},
1313
"repository": {
1414
"type": "git",
15-
"url": "git://github.com/AlexDisler/cordova-icon.git"
15+
"url": "git://github.com/AlexisCaffa/cordova-icon.git"
1616
},
1717
"keywords": [
1818
"cordova",
1919
"icon",
2020
"resize"
2121
],
22-
"author": "Alex Disler",
22+
"author": "Alex Disler - Alexis Caffa",
2323
"license": "MIT",
2424
"bugs": {
25-
"url": "https://github.com/AlexDisler/cordova-icon/issues"
25+
"url": "https://github.com/AlexisCaffa/cordova-icon/issues"
2626
},
27-
"homepage": "https://github.com/AlexDisler/cordova-icon",
27+
"homepage": "https://github.com/AlexisCaffa/cordova-icon",
2828
"dependencies": {
2929
"imagemagick": "^0.1.3",
3030
"underscore": "^1.6.0",

0 commit comments

Comments
 (0)