(code: string)
| 491 | } |
| 492 | |
| 493 | function getLocalizeCall(code: string): NodePath<t.CallExpression> { |
| 494 | let callPaths: NodePath<t.CallExpression>[] = []; |
| 495 | babel.transformSync(code, { |
| 496 | code: false, |
| 497 | filename: 'test/file.js', |
| 498 | cwd: '/', |
| 499 | plugins: [ |
| 500 | { |
| 501 | visitor: { |
| 502 | CallExpression(path) { |
| 503 | callPaths.push(path); |
| 504 | }, |
| 505 | }, |
| 506 | }, |
| 507 | ], |
| 508 | }); |
| 509 | const localizeCall = callPaths.find((p) => { |
| 510 | const callee = p.get('callee'); |
| 511 | return callee.isIdentifier() && callee.node.name === '$localize'; |
| 512 | }); |
| 513 | if (!localizeCall) { |
| 514 | throw new Error(`$localize cannot be found in ${code}`); |
| 515 | } |
| 516 | return localizeCall; |
| 517 | } |
no test coverage detected
searching dependent graphs…