Repository: cordova-windows Updated Branches: refs/heads/master bf505cc69 -> 50730294f
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/50730294 Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/50730294 Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/50730294 Branch: refs/heads/master Commit: 50730294f4d041f11f83d69dce6739674ff4d4e7 Parents: bf505cc Author: Jesse MacFadyen <purplecabb...@gmail.com> Authored: Tue Oct 11 23:26:01 2016 -0700 Committer: Jesse MacFadyen <purplecabb...@gmail.com> Committed: Tue Oct 11 23:27:56 2016 -0700 ---------------------------------------------------------------------- template/cordova/Api.js | 50 +++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/50730294/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-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org