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