You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2016/10/12 05:39:23 UTC

ios commit: CB-11999 - platformAPIs contain js code that is deceptively uncallable

Repository: cordova-ios
Updated Branches:
  refs/heads/master 815a1a525 -> 2cdb60746


CB-11999 - platformAPIs contain js code that is deceptively uncallable

This closes #268


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

Branch: refs/heads/master
Commit: 2cdb6074626cc4efc8ad117058c49d945ead0eb5
Parents: 815a1a5
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Oct 11 17:40:56 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Oct 11 22:38:50 2016 -0700

----------------------------------------------------------------------
 bin/templates/scripts/cordova/Api.js | 45 ++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2cdb6074/bin/templates/scripts/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index 8ddbfaf..b95f8e8 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -115,15 +115,22 @@ Api.createPlatform = function (destination, config, options, events) {
     // because node and shell scripts handles unicode symbols differently
     // We need to normalize the name to NFD form since iOS uses NFD unicode form
     var name = unorm.nfd(config.name());
-
-    return require('../../../lib/create')
-    .createProject(destination, config.packageName(), name, options)
-    .then(function () {
-        // after platform is created we return Api instance based on new Api.js location
-        // This is required to correctly resolve paths in the future api calls
-        var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
-        return new PlatformApi('ios', destination, events);
-    });
+    var result;
+    try {
+        result = require('../../../lib/create')
+        .createProject(destination, config.packageName(), name, options)
+        .then(function () {
+            // after platform is created we return Api instance based on new Api.js location
+            // This is required to correctly resolve paths in the future api calls
+            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+            return new PlatformApi('ios', destination, events);
+        });
+    }
+    catch(e) {
+        events.emit('error','createPlatform is not callable from the iOS project API.');
+        throw(e);
+    }
+    return result;
 };
 
 /**
@@ -145,12 +152,20 @@ Api.createPlatform = function (destination, config, options, events) {
 Api.updatePlatform = function (destination, options, events) {
     setupEvents(events);
 
-    return require('../../../lib/create')
-    .updateProject(destination, options)
-    .then(function () {
-        var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
-        return new PlatformApi('ios', destination, events);
-    });
+    var result;
+    try {
+        result = require('../../../lib/create')
+        .updateProject(destination, options)
+        .then(function () {
+            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+            return new PlatformApi('ios', destination, events);
+        });
+    }
+    catch (e) {
+        events.emit('error','updatePlatform is not callable from the iOS project API, you will need to do this manually.');
+        throw(e);
+    }
+    return result;
 };
 
 /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org