MCPcopy
hub / github.com/facebook/react / buildGateCondition

Function buildGateCondition

scripts/babel/transform-test-gate-pragma.js:241–266  ·  view source on GitHub ↗
(comments)

Source from the content-addressed store, hash-verified

239 }
240
241 function buildGateCondition(comments) {
242 let conditions = null;
243 for (const line of comments) {
244 const commentStr = line.value.trim();
245 if (commentStr.startsWith('@gate ')) {
246 const code = commentStr.slice(6);
247 const ctxIdentifier = t.identifier('ctx');
248 const condition = parse(code, ctxIdentifier);
249 if (conditions === null) {
250 conditions = [condition];
251 } else {
252 conditions.push(condition);
253 }
254 }
255 }
256 if (conditions !== null) {
257 let condition = conditions[0];
258 for (let i = 1; i < conditions.length; i++) {
259 const right = conditions[i];
260 condition = t.logicalExpression('&&', condition, right);
261 }
262 return condition;
263 } else {
264 return null;
265 }
266 }
267
268 return {
269 name: 'test-gate-pragma',

Callers 1

ExpressionStatementFunction · 0.85

Calls 2

parseFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected