Skip to content

Commit

Permalink
limit results after reversing
Browse files Browse the repository at this point in the history
  • Loading branch information
BuZZ-T committed May 8, 2022
1 parent 81e32f5 commit 6736aa6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ describe('versions', () => {
expect(mapped).toEqual(expectedVersions)
})

it('should first limit and then sort the results on --inverse and --max-results', () => {
it('should first sort, then inverse and then limit the results on --inverse and --max-results', () => {
const config = createChromeFullConfig({
inverse: true,
results: 2,
Expand All @@ -1222,17 +1222,17 @@ describe('versions', () => {

const expectedVersions = [
new MappedVersion({
major: 30,
minor: 0,
branch: 0,
patch: 0,
major: 10,
minor: 1,
branch: 2,
patch: 4,
disabled: false
}),
new MappedVersion({
major: 60,
minor: 6,
branch: 7,
patch: 8,
major: 29,
minor: 0,
branch: 2000,
patch: 4,
disabled: false
}),
]
Expand Down
14 changes: 7 additions & 7 deletions versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ export function mapVersions(versions: string[], config: IChromeConfig, store: St
&& ComparableVersion.compare(version.comparable, config.max) !== Compared.GREATER)
.sort(sortDescendingMappedVersions)

const versionRegardingInverse = config.inverse
? filteredVersions.reverse()
: filteredVersions

// Don't reduce the amount of filtered versions when --only-newest-major is set
// because the newest available major version might be disabled for the current os
const limitedVersions = config.onlyNewestMajor
? filteredVersions
: filteredVersions.slice(0, Number(config.results))

return config.inverse
? limitedVersions.reverse()
: limitedVersions
return config.onlyNewestMajor
? versionRegardingInverse
: versionRegardingInverse.slice(0, Number(config.results))
}

0 comments on commit 6736aa6

Please sign in to comment.