mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
CB-7512 Use aligned apk rather than unaligned apk when sorting
This commit is contained in:
parent
533677df8b
commit
a5d300c6ff
20
bin/templates/cordova/lib/build.js
vendored
20
bin/templates/cordova/lib/build.js
vendored
@ -38,8 +38,11 @@ function find_files(directory, predicate) {
|
|||||||
p = path.join(directory, p);
|
p = path.join(directory, p);
|
||||||
return { p: p, t: fs.statSync(p).mtime };
|
return { p: p, t: fs.statSync(p).mtime };
|
||||||
}).sort(function(a,b) {
|
}).sort(function(a,b) {
|
||||||
return a.t > b.t ? -1 :
|
var timeDiff = b.t - a.t;
|
||||||
a.t < b.t ? 1 : 0;
|
if (timeDiff === 0) {
|
||||||
|
return a.p.length - b.p.length;
|
||||||
|
}
|
||||||
|
return timeDiff;
|
||||||
}).map(function(p) { return p.p; });
|
}).map(function(p) { return p.p; });
|
||||||
return candidates;
|
return candidates;
|
||||||
} else {
|
} else {
|
||||||
@ -151,8 +154,9 @@ var builders = {
|
|||||||
console.error('ERROR : No .apk found in ' + binDir + ' directory');
|
console.error('ERROR : No .apk found in ' + binDir + ' directory');
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
console.log('Using apk: ' + candidates[0]);
|
var ret = candidates[0];
|
||||||
return [candidates[0]];
|
console.log('Using apk: ' + ret);
|
||||||
|
return [ret];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gradle: {
|
gradle: {
|
||||||
@ -245,14 +249,16 @@ var builders = {
|
|||||||
var candidates = find_files(binDir, function(candidate) {
|
var candidates = find_files(binDir, function(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 (path.extname(candidate) == '.apk' && candidate.indexOf('-debug-') >= 0);
|
return (path.extname(candidate) == '.apk' && candidate.indexOf('-debug') >= 0);
|
||||||
}
|
}
|
||||||
if (build_type === 'release') {
|
if (build_type === 'release') {
|
||||||
return (path.extname(candidate) == '.apk' && candidate.indexOf('-release-') >= 0);
|
return (path.extname(candidate) == '.apk' && candidate.indexOf('-release') >= 0);
|
||||||
}
|
}
|
||||||
return path.extname(candidate) == '.apk';
|
return path.extname(candidate) == '.apk';
|
||||||
});
|
});
|
||||||
return candidates;
|
var ret = candidates[0];
|
||||||
|
console.log('Using apk: ' + ret);
|
||||||
|
return [ret];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user