Skip to content

Commit

Permalink
Rewritted Promise race to regular for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebryu committed Sep 26, 2023
1 parent 02c65f5 commit dbdcafb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ async function detectReactComponentInFile(filename) {
;
async function detectFunction(changedFiles) {
const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx'));
return Promise.race(_.map(filteredFiles, ({ filename }) => detectReactComponentInFile(filename)));
for (const file of filteredFiles) {
const result = await detectReactComponentInFile(file.filename);
if (result) {
return true; // If the check is true, exit directly
}
}
return false;
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ async function detectReactComponentInFile(filename) {
;
async function detectFunction(changedFiles) {
const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx'));
return Promise.race(_.map(filteredFiles, ({ filename }) => detectReactComponentInFile(filename)));
for (const file of filteredFiles) {
const result = await detectReactComponentInFile(file.filename);
if (result) {
return true; // If the check is true, exit directly
}
}
return false;
};

module.exports = {
Expand Down

0 comments on commit dbdcafb

Please sign in to comment.