(
fileContent: string,
importName: string,
directoryPath: string,
)
| 36 | * @example "/users/foo/path/to/project/styles/foo.css" |
| 37 | */ |
| 38 | export function findImportPath( |
| 39 | fileContent: string, |
| 40 | importName: string, |
| 41 | directoryPath: string, |
| 42 | ): string { |
| 43 | const re = genImportRegExp(importName); |
| 44 | const results = re.exec(fileContent); |
| 45 | |
| 46 | if (results == null) { |
| 47 | return ''; |
| 48 | } |
| 49 | |
| 50 | const rawImportedFrom = results[1]; |
| 51 | |
| 52 | // "./style.modules.css" or "../../style.modules.css" |
| 53 | if (isRelativeFilePath(rawImportedFrom)) { |
| 54 | return path.resolve(directoryPath, results[1]); |
| 55 | } |
| 56 | |
| 57 | return ( |
| 58 | resolveAliasedImport({ |
| 59 | importFilepath: rawImportedFrom, |
| 60 | location: directoryPath, |
| 61 | }) ?? '' |
| 62 | ); |
| 63 | } |
| 64 | |
| 65 | export type StringTransformer = (str: string) => string; |
| 66 | export function getTransformer( |
no test coverage detected