( current: string, root: string = current, )
| 66 | * Search up for the nearest `package.json` |
| 67 | */ |
| 68 | export function searchForPackageRoot( |
| 69 | current: string, |
| 70 | root: string = current, |
| 71 | ): string { |
| 72 | if (hasPackageJSON(current)) return current |
| 73 | |
| 74 | const dir = dirname(current) |
| 75 | // reach the fs root |
| 76 | if (!dir || dir === current) return root |
| 77 | |
| 78 | return searchForPackageRoot(dir, root) |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Search up for the nearest workspace root |
no test coverage detected