Skip to content
This repository was archived by the owner on Oct 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ Automatic icon resizing for Cordova. Create an icon in the root folder of your C

$ sudo npm install cordova-icon -g

### Requirements

- ImageMagick installed (*Mac*: `brew install imagemagick`, *Debian/Ubuntu*: `sudo apt-get install imagemagick`), *Windows*: [See here](http://www.imagemagick.org/script/binary-releases.php#windows))
- At least one platform was added to your project ([cordova platforms docs](http://cordova.apache.org/docs/en/edge/guide_platforms_index.md.html#Platform%20Guides))
- Cordova's config.xml file must exist in the root folder ([cordova config.xml docs](http://cordova.apache.org/docs/en/edge/config_ref_index.md.html#The%20config.xml%20File))

### Usage

Create an ```icon.png``` file in the root folder of your cordova project and run:
Create an `icon.png` file in the root folder of your cordova project and run:

$ cordova-icon

Expand All @@ -34,24 +40,11 @@ Then give the script +x permission:

$ chmod +x hooks/after_prepare/cordova-icon.sh

That's it. Now every time you ```cordova build```, the icons will be auto generated.

### Requirements

- ImageMagick

Install on a Mac:

$ brew install imagemagick

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

- At least one platform was added to your project ([cordova platforms docs](http://cordova.apache.org/docs/en/3.4.0/guide_platforms_index.md.html#Platform%20Guides))
- Cordova's config.xml file must exist in the root folder ([cordova config.xml docs](http://cordova.apache.org/docs/en/3.4.0/config_ref_index.md.html#The%20config.xml%20File))
That's it. Now every time you `cordova build`, the icons will be auto generated.

### Splash screens

check out [cordova-splash](https://github.com/AlexDisler/cordova-splash)
Check out [cordova-splash](https://github.com/AlexDisler/cordova-splash).

### License

Expand Down
25 changes: 23 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var ig = require('imagemagick');
var colors = require('colors');
var _ = require('underscore');
var Q = require('q');
var exec = require('child_process').exec;

/**
* Check which platforms are added to the project and return their icon names and sized
Expand Down Expand Up @@ -156,7 +157,7 @@ var generateIconsForPlatform = function (platform) {

/**
* Goes over all the platforms and triggers icon generation
*
*
* @param {Array} platforms
* @return {Promise}
*/
Expand All @@ -176,6 +177,25 @@ var generateIcons = function (platforms) {
return deferred.promise;
};

/**
* Checks if ImageMagick is installed
*
* @return {Promise} resolves if ImageMagick is installed, rejects otherwise
*/
var imageMagickInstalled = function () {
var deferred = Q.defer();
exec('convert -version', function (error) {
if (!error) {
display.success('ImageMagick found');
deferred.resolve();
} else {
display.error('ImageMagick is not installed/available. Please see README.md for instructions.');
deferred.reject();
}
});
return deferred.promise;
};

/**
* Checks if at least one platform was added to the project
*
Expand Down Expand Up @@ -236,7 +256,8 @@ var configFileExists = function () {

display.header('Checking Project & Icon');

atLeastOnePlatformFound()
imageMagickInstalled()
.then(atLeastOnePlatformFound)
.then(validIconExists)
.then(configFileExists)
.then(getProjectName)
Expand Down