(base: string, moduleDirs: readonly string[])
| 9 | } |
| 10 | |
| 11 | export async function findPackageJson(base: string, moduleDirs: readonly string[]) { |
| 12 | const { root } = path.parse(base); |
| 13 | let current = base; |
| 14 | |
| 15 | while (current !== root && !isModuleDir(current, moduleDirs)) { |
| 16 | const pkgJsonPath = path.join(current, 'package.json'); |
| 17 | if (await fileExists(pkgJsonPath)) { |
| 18 | const pkgJsonString = fs.readFileSync(pkgJsonPath, 'utf-8'); |
| 19 | return { pkgJson: JSON.parse(pkgJsonString), pkgPath: current, pkgJsonPath }; |
| 20 | } |
| 21 | current = path.resolve(current, '..'); |
| 22 | } |
| 23 | return null; |
| 24 | } |
| 25 | |
| 26 | export function isUrl(str: string) { |
| 27 | try { |
no test coverage detected