Skip to content

Commit 4de0391

Browse files
committed
Refactor to allow no repository in crawl results
1 parent 05a06e1 commit 4de0391

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

crawl/ecosystem.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ async function crawlRepo(repo) {
543543
* @type {({
544544
* errors?: Array<string>,
545545
* data: {
546-
* repository: {
546+
* repository?: {
547547
* defaultBranchRef?: {name: string},
548548
* dependencyGraphManifests?: {nodes?: Array<{exceedsMaxSize: boolean, filename: string, parseable: boolean}>},
549549
* diskUsage: number
@@ -624,7 +624,7 @@ async function crawlRepo(repo) {
624624
/** @type {Array<string>} */
625625
const manifests = []
626626

627-
if (defaultBranch && repository.dependencyGraphManifests?.nodes) {
627+
if (defaultBranch && repository?.dependencyGraphManifests?.nodes) {
628628
for (const d of repository.dependencyGraphManifests.nodes) {
629629
if (
630630
d.filename.endsWith('package.json') &&
@@ -639,7 +639,7 @@ async function crawlRepo(repo) {
639639
/** @type {Array<string>} */
640640
const topics = []
641641

642-
if (repository.repositoryTopics?.nodes) {
642+
if (repository?.repositoryTopics?.nodes) {
643643
for (const d of repository.repositoryTopics.nodes) {
644644
const name = d.topic.name
645645
if (validTag(name)) {
@@ -651,19 +651,19 @@ async function crawlRepo(repo) {
651651
return {
652652
project: {
653653
default: defaultBranch,
654-
description: repository.description || '',
654+
description: repository?.description || '',
655655
hasPackages: false,
656-
issueClosed: repository.issueClosed?.totalCount || 0,
657-
issueOpen: repository.issueOpen?.totalCount || 0,
656+
issueClosed: repository?.issueClosed?.totalCount || 0,
657+
issueOpen: repository?.issueOpen?.totalCount || 0,
658658
manifests,
659-
prClosed: repository.prClosed?.totalCount || 0,
660-
prOpen: repository.prOpen?.totalCount || 0,
659+
prClosed: repository?.prClosed?.totalCount || 0,
660+
prOpen: repository?.prOpen?.totalCount || 0,
661661
repo,
662662
// Size of repo in bytes.
663-
size: repository.diskUsage * 1024,
664-
stars: repository.stargazers?.totalCount || 0,
663+
size: (repository?.diskUsage || 0) * 1024,
664+
stars: repository?.stargazers?.totalCount || 0,
665665
topics,
666-
url: repository.homepageUrl || undefined
666+
url: repository?.homepageUrl || undefined
667667
},
668668
releases
669669
}

0 commit comments

Comments
 (0)