Skip to content

Commit 9f98e21

Browse files
committed
fix[devtools/ci]: fixed incorrect condition calculation for @reactVersion annotation
1 parent 70e998a commit 9f98e21

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

scripts/babel/transform-react-version-pragma.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,29 @@ function transform(babel) {
2626
return null;
2727
}
2828

29-
let conditions = null;
30-
for (const line of comments) {
31-
const commentStr = line.value.trim();
32-
if (commentStr.startsWith(GATE_VERSION_STR)) {
33-
const condition = t.stringLiteral(
34-
commentStr.slice(GATE_VERSION_STR.length)
35-
);
36-
if (conditions === null) {
37-
conditions = [condition];
38-
} else {
39-
conditions.push(condition);
29+
const resultingCondition = comments.reduce(
30+
(accumulatedCondition, commentLine) => {
31+
const commentStr = commentLine.value.trim();
32+
33+
if (!commentStr.startsWith(GATE_VERSION_STR)) {
34+
return accumulatedCondition;
35+
}
36+
37+
const condition = commentStr.slice(GATE_VERSION_STR.length);
38+
if (accumulatedCondition === null) {
39+
return condition;
4040
}
41-
}
42-
}
4341

44-
if (conditions !== null) {
45-
let condition = conditions[0];
46-
for (let i = 1; i < conditions.length; i++) {
47-
const right = conditions[i];
48-
condition = t.logicalExpression('&&', condition, right);
49-
}
50-
return condition;
51-
} else {
42+
return accumulatedCondition.concat(' ', condition);
43+
},
44+
null
45+
);
46+
47+
if (resultingCondition === null) {
5248
return null;
5349
}
50+
51+
return t.stringLiteral(resultingCondition);
5452
}
5553

5654
return {

scripts/circleci/run_devtools_e2e_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function runTestShell() {
7676
// Assume the test shell server failed to start.
7777
logError('Testing shell server failed to start');
7878
exitWithCode(1);
79-
}, 30000);
79+
}, 60 * 1000);
8080

8181
logBright('Starting testing shell server');
8282

0 commit comments

Comments
 (0)