Skip to content

Commit d2ffdf5

Browse files
committed
Fix changeset list command to respect the $top parameter
1 parent 78ea5a7 commit d2ffdf5

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

  • src/commands/imodel/changeset

src/commands/imodel/changeset/list.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See LICENSE.md in the project root for license terms and full copyright notice.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Changeset, ChangesetOrderByProperty, OrderBy, OrderByOperator } from "@itwin/imodels-client-management";
6+
import { Changeset, ChangesetOrderByProperty, OrderBy, OrderByOperator, take, toArray } from "@itwin/imodels-client-management";
77
import { Flags } from "@oclif/core";
88

99
import BaseCommand from "../../../extensions/base-command.js";
@@ -84,15 +84,8 @@ export default class ListChangesets extends BaseCommand {
8484
urlParams
8585
});
8686

87-
const result: Changeset[] = [];
88-
for await (const changeset of changesetList) {
89-
if(flags.top && result.length >= flags.top) {
90-
break;
91-
}
87+
const result : Changeset[] = await (flags.top ? take(changesetList, flags.top) : toArray(changesetList));
9288

93-
result.push(changeset);
94-
}
95-
9689
return this.logAndReturnResult(result);
9790
}
9891
}

0 commit comments

Comments
 (0)