diff --git a/src/repos.ts b/src/repos.ts index 3604baab..7ff8bdab 100644 --- a/src/repos.ts +++ b/src/repos.ts @@ -134,18 +134,22 @@ export class Repos extends ConfigFile { private async addAdditionalInfo(repo: Repository): Promise { const location = repo.location || path.join(this.directory.name, repo.org, repo.name); - const pkgJsonPath = path.join(location, 'package.json'); - const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8')) as { name: string }; - repo.npm = { name: pkgJson.name }; - - const npmInfoRaw = exec(`npm view ${pkgJson.name} --json`, { silent: true }).stdout; - const npmInfo = JSON.parse(npmInfoRaw) as { - 'dist-tags': Record; - versions: string[]; - }; - repo.npm.version = npmInfo['dist-tags']['latest'] ?? npmInfo.versions.reverse()[0]; - repo.npm.tags = npmInfo['dist-tags']; repo.location = location; + const pkgJsonPath = path.join(location, 'package.json'); + try { + const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8')) as { name: string }; + repo.npm = { name: pkgJson.name }; + + const npmInfoRaw = exec(`npm view ${pkgJson.name} --json`, { silent: true }).stdout; + const npmInfo = JSON.parse(npmInfoRaw) as { + 'dist-tags': Record; + versions: string[]; + }; + repo.npm.version = npmInfo['dist-tags']['latest'] ?? npmInfo.versions.reverse()[0]; + repo.npm.tags = npmInfo['dist-tags']; + } catch { + // likely not an npm package, which is okay + } return repo; } }