Skip to content

Commit

Permalink
Find the correct last index if there is package with different configs (
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanduplenskikh authored Nov 2, 2023
1 parent c140006 commit 0877a74
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ci/courtesy-push/courtesy-push.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ function formatDeps(depArr) {
return newDepsDict;
}

function findLastIndex(array, predicate) {
let l = array.length;

while (l--) {
if (predicate(array[l], l, array)) {
return l;
}
}
return -1;
}

/* Function updating existing deps version and also add new deps with postfix
* Example: If we have dependency with name
* Mseng.MS.TF.DistributedTask.Tasks.AndroidSigningV2
Expand Down Expand Up @@ -81,12 +92,12 @@ function updateUnifiedDeps(pathToUnifiedDeps, pathToNewUnifiedDeps, outputPath)
// Mseng.MS.TF.DistributedTask.Tasks.AndroidSigningV2-Node16(packageName) should include
// Mseng.MS.TF.DistributedTask.Tasks.AndroidSigningV2(basePackageName)
const depToBeInserted = newDepsArr.find(dep => dep.includes(packageName));
const pushingIndex = updatedDeps.findIndex(basePackage => {
const pushingIndex = findLastIndex(updatedDeps, basePackage => {
if (!basePackage) return false;

const depDetails = basePackage.split('"');
const name = depDetails[1];
return name && name.startsWith(msPrefix) && packageName.includes(name)
return name && name.startsWith(msPrefix) && packageName.includes(name.split("_")[0])
});

if (pushingIndex !== -1) {
Expand Down

0 comments on commit 0877a74

Please sign in to comment.