Skip to content

Commit b39b04a

Browse files
authored
feat(cli): match --keys via minimatch in run (#948)
https://www.npmjs.com/package/minimatch
1 parent 4e5983d commit b39b04a

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

.changeset/famous-shrimps-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
match --keys via minimatch in run

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"@changesets/changelog-github": "^0.5.0",
2626
"@changesets/cli": "^2.27.10",
27+
"minimatch": "^10.0.3",
2728
"node-machine-id": "^1.1.12"
2829
},
2930
"packageManager": "[email protected]"

packages/cli/src/cli/cmd/run/execute.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import chalk from "chalk";
22
import { Listr, ListrTask } from "listr2";
33
import pLimit, { LimitFunction } from "p-limit";
44
import _ from "lodash";
5+
import { minimatch } from "minimatch";
56

67
import { colors } from "../../constants";
78
import { CmdRunContext, CmdRunTask, CmdRunTaskResult } from "./_types";
@@ -168,10 +169,10 @@ function createWorkerTask(args: {
168169
delta.updated.includes(key) ||
169170
!!args.ctx.flags.force,
170171
)
171-
.filter(
172-
([key]) =>
173-
!assignedTask.onlyKeys.length ||
174-
assignedTask.onlyKeys.includes(key),
172+
.filter(([key]) =>
173+
assignedTask.onlyKeys?.some((pattern) =>
174+
minimatch(key, pattern),
175+
),
175176
)
176177
.fromPairs()
177178
.value();

packages/cli/src/cli/cmd/run/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default new Command()
4040
)
4141
.option(
4242
"--key <key>",
43-
"Key to process. Process only a specific translation key, useful for updating a single entry",
43+
"Key to process. Process only a specific translation key, useful for updating a single entry. Accepts glob patterns.",
4444
(val: string, prev: string[]) => (prev ? [...prev, val] : [val]),
4545
)
4646
.option(

pnpm-lock.yaml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)