| 419 | ); |
| 420 | |
| 421 | const findRequirePathAndBinding = (moduleName) => { |
| 422 | let result = null; |
| 423 | const requireCall = root.find(j.VariableDeclarator, { |
| 424 | id: {type: 'Identifier'}, |
| 425 | init: { |
| 426 | callee: {name: 'require'}, |
| 427 | arguments: [{value: moduleName}], |
| 428 | }, |
| 429 | }); |
| 430 | |
| 431 | const importStatement = root.find(j.ImportDeclaration, { |
| 432 | source: { |
| 433 | value: moduleName, |
| 434 | }, |
| 435 | }); |
| 436 | |
| 437 | if (importStatement.size()) { |
| 438 | importStatement.forEach(path => { |
| 439 | result = { |
| 440 | path, |
| 441 | binding: path.value.specifiers[0].local.name, |
| 442 | type: 'import', |
| 443 | }; |
| 444 | }); |
| 445 | } else if (requireCall.size()) { |
| 446 | requireCall.forEach(path => { |
| 447 | result = { |
| 448 | path, |
| 449 | binding: path.value.id.name, |
| 450 | type: 'require', |
| 451 | }; |
| 452 | }); |
| 453 | } |
| 454 | |
| 455 | return result; |
| 456 | }; |
| 457 | |
| 458 | const pureRenderMixinPathAndBinding = findRequirePathAndBinding(PURE_MIXIN_MODULE_NAME); |
| 459 | |