From dbdcafb8903054f7c79654888def78e79747eff8 Mon Sep 17 00:00:00 2001 From: Sebastian Szewczyk Date: Tue, 26 Sep 2023 12:31:39 +0200 Subject: [PATCH] Rewritted Promise race to regular for loop --- .github/actions/javascript/authorChecklist/index.js | 8 +++++++- .../javascript/authorChecklist/newComponentCategory.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 9b488f0b172d..3a899312a257 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -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 = { diff --git a/.github/actions/javascript/authorChecklist/newComponentCategory.js b/.github/actions/javascript/authorChecklist/newComponentCategory.js index 069b81fe53a4..91cbcb29aabc 100644 --- a/.github/actions/javascript/authorChecklist/newComponentCategory.js +++ b/.github/actions/javascript/authorChecklist/newComponentCategory.js @@ -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 = {