(nodePath, state)
| 1 | import defaultResolvePath from './resolvePath'; |
| 2 | |
| 3 | export default function mapPathString(nodePath, state) { |
| 4 | if (!state.types.isStringLiteral(nodePath)) { |
| 5 | return; |
| 6 | } |
| 7 | |
| 8 | const sourcePath = nodePath.node.value; |
| 9 | const currentFile = state.file.opts.filename; |
| 10 | const resolvePath = state.normalizedOpts.customResolvePath || defaultResolvePath; |
| 11 | |
| 12 | const modulePath = resolvePath(sourcePath, currentFile, state.opts); |
| 13 | if (modulePath) { |
| 14 | if (nodePath.node.pathResolved) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | nodePath.replaceWith(state.types.stringLiteral(modulePath)); |
| 19 | nodePath.node.pathResolved = true; |
| 20 | } |
| 21 | } |
no test coverage detected