Skip to content

Commit 678dbae

Browse files
committed
feat(cli): add --grep option for list
Filter version
1 parent d3bf49b commit 678dbae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bin/cli.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cli.command('<version>', 'Get a changeset for specific version')
2828
cli.command('list', 'List changesets')
2929
.option('--min <version>', 'Minimum version (included)')
3030
.option('--max <version>', 'Maximum version (included)')
31+
.option('--grep <version>', 'Grep version')
3132
.option('--json', 'Output in json format')
3233
.option('--all', 'List all changesets (alpha/beta included)')
3334
.option('--beta', 'List alpha/beta changesets')
@@ -42,10 +43,9 @@ cli.command('list', 'List changesets')
4243
// Filter by min/max.
4344
var min = options.min ? toNumber(options.min) : Number.MIN_VALUE;
4445
var max = options.max ? toNumber(options.max) : Number.MAX_VALUE;
45-
results = results.filter(r => {
46-
const n = toNumber(r.version);
47-
return min <= n && n <= max;
48-
});
46+
results = results
47+
.filter(r => r.version.includes(options.grep || ''))
48+
.filter(r => min <= toNumber(r.version) && toNumber(r.version) <= max);
4949

5050
if (options.json) {
5151
if (options.versions)
@@ -69,7 +69,7 @@ cli
6969
.example('unity-changeset list --beta')
7070
.example('unity-changeset list --versions')
7171
.help()
72-
.version('1.1.0');
72+
.version('1.2.0');
7373

7474
if (process.argv.length < 3) {
7575
cli.outputHelp(true);

0 commit comments

Comments
 (0)