(dir: string)
| 200 | ): string | undefined => { |
| 201 | if (!isAbsolute(file)) return |
| 202 | const nameIn = (dir: string): string | undefined => { |
| 203 | if (dir in namesByDir) return namesByDir[dir] |
| 204 | let name: unknown |
| 205 | try { |
| 206 | const manifestPath = join(dir, "package.json") |
| 207 | const manifest = readFile(manifestPath) |
| 208 | if (manifest !== undefined) |
| 209 | name = parsePackageManifest(manifest, manifestPath).name |
| 210 | } catch { |
| 211 | // one that doesn't parse names nothing |
| 212 | } |
| 213 | return (namesByDir[dir] = |
| 214 | typeof name === "string" ? name |
| 215 | : dir === dirname(dir) ? undefined |
| 216 | : nameIn(dirname(dir))) |
| 217 | } |
| 218 | return nameIn(dirname(file)) |
| 219 | } |
| 220 |
no test coverage detected