Skip to content

Commit

Permalink
Filter empty version on single version query
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Sep 25, 2021
1 parent c7f5c48 commit 185e20a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/strategy/organization-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ module.exports = class OrganizationStrategy extends Strategy {

// Normalize results of each query so that we get a `versions` array for each package in either case.
if (this.version) {
return result.organization.packages.nodes.map((it) => ({ ...it, versions: [it.version] }))
return result.organization.packages.nodes
.filter((it) => !!it.version)
.map((it) => ({ ...it, versions: [it.version] }))
} else {
return result.organization.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes }))
}
Expand Down
4 changes: 3 additions & 1 deletion src/strategy/repo-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ module.exports = class RepoStrategy extends Strategy {

// Normalize results of each query so that we get a `versions` array for each package in either case.
if (this.version) {
return result.repository.packages.nodes.map((it) => ({ ...it, versions: [it.version] }))
return result.repository.packages.nodes
.filter((it) => !!it.version)
.map((it) => ({ ...it, versions: [it.version] }))
} else {
return result.repository.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes }))
}
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/user-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = class UserStrategy extends Strategy {

// Normalize results of each query so that we get a `versions` array for each package in either case.
if (this.version) {
return result.user.packages.nodes.map((it) => ({ ...it, versions: [it.version] }))
return result.user.packages.nodes.filter((it) => !!it.version).map((it) => ({ ...it, versions: [it.version] }))
} else {
return result.user.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes }))
}
Expand Down

0 comments on commit 185e20a

Please sign in to comment.