(path: string)
| 92 | |
| 93 | /** Fetch the file and directory paths from a path, uri, or `import.meta.url` */ |
| 94 | export const filePath = (path: string): string => { |
| 95 | let file: string |
| 96 | if (path.includes("://")) { |
| 97 | // is a url, e.g. file://, or https:// |
| 98 | const url = new URL(path) |
| 99 | file = url.protocol === "file:" ? fileURLToPath(url) : url.href |
| 100 | } else { |
| 101 | // is already a typical path |
| 102 | file = path |
| 103 | } |
| 104 | return file |
| 105 | } |
| 106 | |
| 107 | const fileOfCaller = () => |
| 108 | filePath(caller({ methodName: "fileOfCaller", upStackBy: 1 }).file) |
no outgoing calls
no test coverage detected