ubuntu: check icon existence

Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ead6074d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ead6074d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ead6074d

Branch: refs/heads/master
Commit: ead6074df288916c5ec033ddda1af69fc4e3a45f
Parents: 38e04e1
Author: Maxim Ermilov <[email protected]>
Authored: Tue Aug 19 15:03:48 2014 +0400
Committer: Andrew Grieve <[email protected]>
Committed: Wed Aug 20 10:41:18 2014 -0400

----------------------------------------------------------------------
 .../src/cordova/metadata/ubuntu_parser.js       | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ead6074d/cordova-lib/src/cordova/metadata/ubuntu_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/ubuntu_parser.js 
b/cordova-lib/src/cordova/metadata/ubuntu_parser.js
index 634a575..a199662 100644
--- a/cordova-lib/src/cordova/metadata/ubuntu_parser.js
+++ b/cordova-lib/src/cordova/metadata/ubuntu_parser.js
@@ -87,14 +87,18 @@ module.exports.prototype = {
                          architecture: arch,
                          description: sanitize(this.config.description()) };
 
-        var name = this.config.name().replace(/\n/g, ' '); //FIXME: escaping
-        var content = '[Desktop Entry]\nName=' + name + 
'\nExec=./cordova-ubuntu 
www/\nIcon=qmlscene\nTerminal=false\nType=Application\nX-Ubuntu-Touch=true';
-
-        name = sanitize(this.config.name()); //FIXME: escaping
-        content = '[Desktop Entry]\nName=' + name + '\nExec=./cordova-ubuntu 
www/\nTerminal=false\nType=Application\nX-Ubuntu-Touch=true';
-
-        if (this.config.doc.find('icon') && 
this.config.doc.find('icon').attrib.src && fs.existsSync(path.join(this.path, 
'www', this.config.doc.find('icon').attrib.src))) {
-            content += '\nIcon=www/' + this.config.doc.find('icon').attrib.src;
+        var name = sanitize(this.config.name()); //FIXME: escaping
+        var content = '[Desktop Entry]\nName=' + name + 
'\nExec=./cordova-ubuntu 
www/\nTerminal=false\nType=Application\nX-Ubuntu-Touch=true';
+
+        if (this.config.doc.find('icon') && 
this.config.doc.find('icon').attrib.src) {
+            var iconPath = path.join(this.path, 'www', 
this.config.doc.find('icon').attrib.src);
+            if (fs.existsSync(iconPath))
+                content += '\nIcon=www/' + 
this.config.doc.find('icon').attrib.src;
+            else
+                return Q.reject(new Error('icon does not exist: ' + iconPath));
+        } else {
+            content += '\nIcon=qmlscene';
+            console.warn('missing icon element in config.xml');
         }
         fs.writeFileSync(path.join(this.path, 'manifest.json'), 
JSON.stringify(manifest));
         fs.writeFileSync(path.join(this.path, 'cordova.desktop'), content);

Reply via email to