@@ -6,6 +6,7 @@ import { getBuckets } from "../utils/buckets";
66import { resolveOverriddenLocale } from "@lingo.dev/_spec" ;
77import createBucketLoader from "../loaders" ;
88import { minimatch } from "minimatch" ;
9+ import { safeDecode } from "../utils/key-matching" ;
910import { confirm } from "@inquirer/prompts" ;
1011
1112interface PurgeOptions {
@@ -123,7 +124,7 @@ export default new Command()
123124 if ( options . key ) {
124125 // minimatch for key patterns
125126 keysToRemove = Object . keys ( newData ) . filter ( ( k ) =>
126- minimatch ( k , options . key ! ) ,
127+ minimatch ( safeDecode ( k ) , safeDecode ( options . key ! ) ) ,
127128 ) ;
128129 } else {
129130 // No key specified: remove all keys
@@ -133,7 +134,7 @@ export default new Command()
133134 // Show what will be deleted
134135 if ( options . key ) {
135136 bucketOra . info (
136- `About to delete ${ keysToRemove . length } key(s) matching '${ options . key } ' from ${ bucketPath . pathPattern } [${ targetLocale } ]:\n ${ keysToRemove . slice ( 0 , 10 ) . join ( ", " ) } ${ keysToRemove . length > 10 ? ", ..." : "" } ` ,
137+ `About to delete ${ keysToRemove . length } key(s) matching '${ safeDecode ( options . key ) } ' from ${ bucketPath . pathPattern } [${ targetLocale } ]:\n ${ keysToRemove . slice ( 0 , 10 ) . join ( ", " ) } ${ keysToRemove . length > 10 ? ", ..." : "" } ` ,
137138 ) ;
138139 } else {
139140 bucketOra . info (
@@ -161,7 +162,7 @@ export default new Command()
161162 await bucketLoader . push ( targetLocale , newData ) ;
162163 if ( options . key ) {
163164 bucketOra . succeed (
164- `Removed ${ keysToRemove . length } key(s) matching '${ options . key } ' from ${ bucketPath . pathPattern } [${ targetLocale } ]` ,
165+ `Removed ${ keysToRemove . length } key(s) matching '${ safeDecode ( options . key ) } ' from ${ bucketPath . pathPattern } [${ targetLocale } ]` ,
165166 ) ;
166167 } else {
167168 bucketOra . succeed (
@@ -170,7 +171,7 @@ export default new Command()
170171 }
171172 } else if ( options . key ) {
172173 bucketOra . info (
173- `No keys matching '${ options . key } ' found in ${ bucketPath . pathPattern } [${ targetLocale } ]` ,
174+ `No keys matching '${ safeDecode ( options . key ) } ' found in ${ bucketPath . pathPattern } [${ targetLocale } ]` ,
174175 ) ;
175176 } else {
176177 bucketOra . info ( "No keys to remove." ) ;
0 commit comments