mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
CB-11999 add message, catch exception if require fails
This commit is contained in:
parent
2532c4a39e
commit
b2d7124424
42
bin/templates/cordova/Api.js
vendored
42
bin/templates/cordova/Api.js
vendored
@ -109,13 +109,20 @@ function Api(platform, platformRootDir, events) {
|
|||||||
*/
|
*/
|
||||||
Api.createPlatform = function (destination, config, options, events) {
|
Api.createPlatform = function (destination, config, options, events) {
|
||||||
events = setupEvents(events);
|
events = setupEvents(events);
|
||||||
|
var result;
|
||||||
return require('../../lib/create')
|
try {
|
||||||
.create(destination, config, options, events)
|
result = require('../../lib/create')
|
||||||
.then(function (destination) {
|
.create(destination, config, options, events)
|
||||||
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
.then(function (destination) {
|
||||||
return new PlatformApi(PLATFORM, destination, events);
|
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
||||||
});
|
return new PlatformApi(PLATFORM, destination, events);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
events.emit('error','createPlatform is not callable from the android project API.');
|
||||||
|
throw(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,13 +143,20 @@ Api.createPlatform = function (destination, config, options, events) {
|
|||||||
*/
|
*/
|
||||||
Api.updatePlatform = function (destination, options, events) {
|
Api.updatePlatform = function (destination, options, events) {
|
||||||
events = setupEvents(events);
|
events = setupEvents(events);
|
||||||
|
var result;
|
||||||
return require('../../lib/create')
|
try {
|
||||||
.update(destination, options, events)
|
result = require('../../lib/create')
|
||||||
.then(function (destination) {
|
.update(destination, options, events)
|
||||||
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
.then(function (destination) {
|
||||||
return new PlatformApi('android', destination, events);
|
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
||||||
});
|
return new PlatformApi('android', destination, events);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
events.emit('error','updatePlatform is not callable from the android project API, you will need to do this manually.');
|
||||||
|
throw(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user