mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
refactor(ProjectBuilder): clean up output file collection code (#1099)
* refactor(ProjectBuilder): less repetitive fileSorter This reverts the fileSorter to the state from before #937, but using our own simple re-implementation of `compare-func`. * fix(ProjectBuilder): apply sort RegExp to basename only * refactor(ProjectBuilder): use fast-glob instead of hand-rolled equivalent * refactor(ProjectBuilder): factor out common isPathArchSpecific * refactor(ProjectBuilder): use includes instead of indexOf * refactor(ProjectBuilder): move sorting into findOutputFilesHelper * refactor(ProjectBuilder): simplify findOutputFiles signature
This commit is contained in:
committed by
GitHub
parent
bb7d733cde
commit
b245337501
Vendored
+14
@@ -39,3 +39,17 @@ exports.replaceFileContents = function (file, searchRegex, replacementString) {
|
||||
contents = contents.replace(searchRegex, replacementString);
|
||||
fs.writeFileSync(file, contents);
|
||||
};
|
||||
|
||||
// Some helpers for easier sorting
|
||||
exports.compare = (a, b) => (a < b && -1) || +(a > b);
|
||||
exports.compareBy = f => (a, b) => exports.compare(f(a), f(b));
|
||||
exports.compareByAll = fns => {
|
||||
const comparators = fns.map(exports.compareBy);
|
||||
return (a, b) => {
|
||||
for (const cmp of comparators) {
|
||||
const result = cmp(a, b);
|
||||
if (result) return result;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user