From e77934e7de1880340d535c327f9829e77fdaf88b Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Fri, 23 Jun 2023 14:53:25 +0100 Subject: [PATCH] fix[devtools/ci]: fixed incorrect condition calculation for @reactVersion annotation --- .../babel/transform-react-version-pragma.js | 35 ++++++++----------- scripts/circleci/run_devtools_e2e_tests.js | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/scripts/babel/transform-react-version-pragma.js b/scripts/babel/transform-react-version-pragma.js index d7d42f865cf80..5d1c1bcaea2b1 100644 --- a/scripts/babel/transform-react-version-pragma.js +++ b/scripts/babel/transform-react-version-pragma.js @@ -26,31 +26,26 @@ function transform(babel) { return null; } - let conditions = null; - for (const line of comments) { - const commentStr = line.value.trim(); - if (commentStr.startsWith(GATE_VERSION_STR)) { - const condition = t.stringLiteral( - commentStr.slice(GATE_VERSION_STR.length) - ); - if (conditions === null) { - conditions = [condition]; - } else { - conditions.push(condition); - } + const resultingCondition = comments.reduce((accumulatedCondition, commentLine) => { + const commentStr = commentLine.value.trim(); + + if (!commentStr.startsWith(GATE_VERSION_STR)) { + return accumulatedCondition; } - } - if (conditions !== null) { - let condition = conditions[0]; - for (let i = 1; i < conditions.length; i++) { - const right = conditions[i]; - condition = t.logicalExpression('&&', condition, right); + const condition = commentStr.slice(GATE_VERSION_STR.length); + if (accumulatedCondition === null) { + return condition; } - return condition; - } else { + + return accumulatedCondition.concat(' ', condition); + }, null); + + if (resultingCondition === null) { return null; } + + return t.stringLiteral(resultingCondition); } return { diff --git a/scripts/circleci/run_devtools_e2e_tests.js b/scripts/circleci/run_devtools_e2e_tests.js index 9e1be94b9904d..e8fdb01c42aa6 100755 --- a/scripts/circleci/run_devtools_e2e_tests.js +++ b/scripts/circleci/run_devtools_e2e_tests.js @@ -76,7 +76,7 @@ function runTestShell() { // Assume the test shell server failed to start. logError('Testing shell server failed to start'); exitWithCode(1); - }, 30000); + }, 60 * 1000); logBright('Starting testing shell server');