You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/10/24 10:35:34 UTC

[12/21] cordova-windows git commit: output message, catch exception if require fails, change eventEmitter to events to be consistent with ios+android

output message, catch exception if require fails, change eventEmitter to events to be consistent with ios+android


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

Branch: refs/heads/4.4.x
Commit: 44e400c496cfbc0b9d304a47bd939dfa18e7551c
Parents: ddb7f39
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Oct 11 23:26:01 2016 -0700
Committer: daserge <v-...@microsoft.com>
Committed: Thu Oct 20 20:54:55 2016 +0300

----------------------------------------------------------------------
 template/cordova/Api.js | 50 +++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/44e400c4/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/template/cordova/Api.js b/template/cordova/Api.js
index 1fb62ce..70e4797 100644
--- a/template/cordova/Api.js
+++ b/template/cordova/Api.js
@@ -86,14 +86,24 @@ function Api(platform, platformRootDir, eventEmitter) {
  * @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi
  *   instance or rejected with CordovaError.
  */
-Api.createPlatform = function (destinationDir, projectConfig, options, eventEmitter) {
-    setupEvents(eventEmitter);
-    return require('../../bin/lib/create')
-    .create(destinationDir, projectConfig, options)
-    .then(function () {
-        var PlatformApi = require(path.resolve(destinationDir, 'cordova/Api'));
-        return new PlatformApi(PLATFORM, destinationDir, eventEmitter);
-    });
+Api.createPlatform = function (destinationDir, projectConfig, options, events) {
+    setupEvents(events);
+    var result;
+
+    try {
+        result = require('../../bin/lib/create')
+        .create(destinationDir, projectConfig, options)
+        .then(function () {
+            var PlatformApi = require(path.resolve(destinationDir, 'cordova/Api'));
+            return new PlatformApi(PLATFORM, destinationDir, events);
+        });
+    }
+    catch(e) {
+        events.emit('error','createPlatform is not callable from the windows project API.');
+        throw(e);
+    }
+
+    return result;
 };
 
 /**
@@ -106,19 +116,25 @@ Api.createPlatform = function (destinationDir, projectConfig, options, eventEmit
  *   should override the default one from platform.
  * @param  {Boolean}  [options.link=false]  Flag that indicates that platform's sources
  *   will be linked to installed platform instead of copying.
- * @param {EventEmitter} [eventEmitter] The emitter that will be used for logging
+ * @param {EventEmitter} [events] The emitter that will be used for logging
  *
  * @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi
  *   instance or rejected with CordovaError.
  */
-Api.updatePlatform = function (destinationDir, options, eventEmitter) {
-    setupEvents(eventEmitter);
-    return require('../../bin/lib/update')
-    .update(destinationDir, options)
-    .then(function () {
-        var PlatformApi = require(path.resolve(destinationDir, 'cordova/Api'));
-        return new PlatformApi(PLATFORM, destinationDir, eventEmitter);
-    });
+Api.updatePlatform = function (destinationDir, options, events) {
+    setupEvents(events);
+    try {
+        return require('../../bin/lib/update')
+        .update(destinationDir, options)
+        .then(function () {
+            var PlatformApi = require(path.resolve(destinationDir, 'cordova/Api'));
+            return new PlatformApi(PLATFORM, destinationDir, events);
+        });
+    }
+    catch(e) {
+        events.emit('error','updatePlatform is not callable from the windows project API.');
+        throw(e);
+    }
 };
 
 /**


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