Skip to content

Commit

Permalink
Sort keys without flat option in default
Browse files Browse the repository at this point in the history
  • Loading branch information
toshitanian committed Mar 2, 2020
1 parent 7260b69 commit 8e0bda8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
4 changes: 0 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const cli = meow(
-f, --format json | yaml [default: json]
-d, --default-locale default locale
--flat json [default: true] | yaml [default: false]
--sort-when-not-flat keys are sorted even when flat option is false [default: false]
Example
$ extract-messages --locales=ja,en --output app/translations 'app/**/*.js'
Expand All @@ -26,9 +25,6 @@ const cli = meow(
flat: {
type: 'boolean'
},
'sort-when-not-flat': {
type: 'boolean'
},
output: {
type: 'string',
alias: 'o'
Expand Down
6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type Opts = {
defaultLocale: string
format?: string
flat?: boolean
sortWhenNotFlat?: boolean
[key: string]: unknown
}

Expand All @@ -73,7 +72,6 @@ const extractMessage = async (
{
format = 'json',
flat = isJson(format),
sortWhenNotFlat = false,
defaultLocale = 'en',
...opts
}: Opts = {
Expand Down Expand Up @@ -123,9 +121,7 @@ const extractMessage = async (

const fomattedLocaleMap: object = flat
? sortKeys(localeMap, { deep: true })
: sortWhenNotFlat
? sortKeys(unflatten(localeMap, { object: true }), { deep: true })
: unflatten(sortKeys(localeMap), { object: true })
: sortKeys(unflatten(localeMap, { object: true }), { deep: true })

const fn = isJson(format) ? writeJson : writeYaml

Expand Down

0 comments on commit 8e0bda8

Please sign in to comment.