Skip to content

Commit

Permalink
Merge pull request #39830 from JKobrynski/checkForUndefinedInPromiseW…
Browse files Browse the repository at this point in the history
…hile

[No QA] Check for undefined in promiseWhile.ts
  • Loading branch information
mountiny authored Apr 9, 2024
2 parents 8a64b29 + 632926f commit eda5932
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12754,9 +12754,13 @@ function promiseDoWhile(condition, action) {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
}
actionResult
?.then(() => promiseWhile(condition, action))
.then(() => resolve())
.then(() => promiseWhile(condition, action))
.then(resolve)
.catch(reject);
});
}
Expand Down
9 changes: 7 additions & 2 deletions .github/libs/promiseWhile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ function promiseDoWhile(condition: () => boolean, action: (() => Promise<void>)
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
}

actionResult
?.then(() => promiseWhile(condition, action))
.then(() => resolve())
.then(() => promiseWhile(condition, action))
.then(resolve)
.catch(reject);
});
}
Expand Down

0 comments on commit eda5932

Please sign in to comment.