mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
CB-9404 Fixed an exception when path contained -debug or -release
This commit is contained in:
parent
37309c23c2
commit
1ad0665eb5
21
bin/templates/cordova/lib/build.js
vendored
21
bin/templates/cordova/lib/build.js
vendored
@ -69,12 +69,13 @@ function isAutoGenerated(file) {
|
|||||||
|
|
||||||
function findOutputApksHelper(dir, build_type, arch) {
|
function findOutputApksHelper(dir, build_type, arch) {
|
||||||
var ret = findApks(dir).filter(function(candidate) {
|
var ret = findApks(dir).filter(function(candidate) {
|
||||||
|
var apkName = path.basename(candidate);
|
||||||
// Need to choose between release and debug .apk.
|
// Need to choose between release and debug .apk.
|
||||||
if (build_type === 'debug') {
|
if (build_type === 'debug') {
|
||||||
return /-debug/.exec(candidate) && !/-unaligned|-unsigned/.exec(candidate);
|
return /-debug/.exec(apkName) && !/-unaligned|-unsigned/.exec(apkName);
|
||||||
}
|
}
|
||||||
if (build_type === 'release') {
|
if (build_type === 'release') {
|
||||||
return /-release/.exec(candidate) && !/-unaligned/.exec(candidate);
|
return /-release/.exec(apkName) && !/-unaligned/.exec(apkName);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -83,16 +84,16 @@ function findOutputApksHelper(dir, build_type, arch) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// Assume arch-specific build if newest apk has -x86 or -arm.
|
// Assume arch-specific build if newest apk has -x86 or -arm.
|
||||||
var archSpecific = !!/-x86|-arm/.exec(ret[0]);
|
var archSpecific = !!/-x86|-arm/.exec(path.basename(ret[0]));
|
||||||
// And show only arch-specific ones (or non-arch-specific)
|
// And show only arch-specific ones (or non-arch-specific)
|
||||||
ret = ret.filter(function(p) {
|
ret = ret.filter(function(p) {
|
||||||
/*jshint -W018 */
|
/*jshint -W018 */
|
||||||
return !!/-x86|-arm/.exec(p) == archSpecific;
|
return !!/-x86|-arm/.exec(path.basename(p)) == archSpecific;
|
||||||
/*jshint +W018 */
|
/*jshint +W018 */
|
||||||
});
|
});
|
||||||
if (archSpecific && ret.length > 1) {
|
if (archSpecific && ret.length > 1) {
|
||||||
ret = ret.filter(function(p) {
|
ret = ret.filter(function(p) {
|
||||||
return p.indexOf('-' + arch) != -1;
|
return path.basename(p).indexOf('-' + arch) != -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,16 +633,18 @@ module.exports.detectArchitecture = function(target) {
|
|||||||
|
|
||||||
module.exports.findBestApkForArchitecture = function(buildResults, arch) {
|
module.exports.findBestApkForArchitecture = function(buildResults, arch) {
|
||||||
var paths = buildResults.apkPaths.filter(function(p) {
|
var paths = buildResults.apkPaths.filter(function(p) {
|
||||||
|
var apkName = path.basename(p);
|
||||||
if (buildResults.buildType == 'debug') {
|
if (buildResults.buildType == 'debug') {
|
||||||
return /-debug/.exec(p);
|
return /-debug/.exec(apkName);
|
||||||
}
|
}
|
||||||
return !/-debug/.exec(p);
|
return !/-debug/.exec(apkName);
|
||||||
});
|
});
|
||||||
var archPattern = new RegExp('-' + arch);
|
var archPattern = new RegExp('-' + arch);
|
||||||
var hasArchPattern = /-x86|-arm/;
|
var hasArchPattern = /-x86|-arm/;
|
||||||
for (var i = 0; i < paths.length; ++i) {
|
for (var i = 0; i < paths.length; ++i) {
|
||||||
if (hasArchPattern.exec(paths[i])) {
|
var apkName = path.basename(paths[i]);
|
||||||
if (archPattern.exec(paths[i])) {
|
if (hasArchPattern.exec(apkName)) {
|
||||||
|
if (archPattern.exec(apkName)) {
|
||||||
return paths[i];
|
return paths[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user