CB-6543 Fix cordova/run failure when no custom_rules.xml available

Github: Close #99
This commit is contained in:
Ningxin Hu 2014-04-24 16:05:42 +08:00 committed by Andrew Grieve
parent 11fc6be328
commit e6adbb0e42

View File

@ -74,7 +74,12 @@ module.exports.run = function(build_type) {
* the script will error out. (should we error or just return undefined?)
*/
module.exports.get_apk = function() {
var binDir = path.join(ROOT, 'ant-build');
var binDir = '';
if(!hasCustomRules()) {
binDir = path.join(ROOT, 'bin');
} else {
binDir = path.join(ROOT, 'ant-build');
}
if (fs.existsSync(binDir)) {
var candidates = fs.readdirSync(binDir).filter(function(p) {
// Need to choose between release and debug .apk.
@ -87,13 +92,13 @@ module.exports.get_apk = function() {
a.t < b.t ? 1 : 0;
});
if (candidates.length === 0) {
console.error('ERROR : No .apk found in \'ant-build\' directory');
console.error('ERROR : No .apk found in ' + binDir + ' directory');
process.exit(2);
}
console.log('Using apk: ' + candidates[0].p);
return candidates[0].p;
} else {
console.error('ERROR : unable to find project ant-build directory, could not locate .apk');
console.error('ERROR : unable to find project ' + binDir + ' directory, could not locate .apk');
process.exit(2);
}
}