Skip to content

Commit

Permalink
💥 breaking(cli): change infuse command options
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Sep 23, 2019
1 parent aaaf986 commit ea812f3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ vue-i18n-locale-message squeeze --target=./src --output=./messages.json
#### Infuse

```sh
vue-i18n-locale-message infuse --target=./src --messages=./translated.json
vue-i18n-locale-message infuse --target=./src --locales=./translated.json
```

## :raising_hand: Motivations
Expand Down
10 changes: 5 additions & 5 deletions src/commands/infuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const debug = Debug('vue-i18n-locale-message:commands:infuse')

type InfuseOptions = {
target: string
messages: string
locales: string
match?: string
}

Expand All @@ -30,22 +30,22 @@ export const builder = (args: Argv): Argv<InfuseOptions> => {
describe: 'target path that single-file components is stored',
demandOption: true
})
.option('messages', {
.option('locales', {
type: 'string',
alias: 'm',
alias: 'l',
describe: 'locale messages path to be infused',
demandOption: true
})
.option('match', {
type: 'string',
alias: 'r',
alias: 'm',
describe: 'option should be accepted a regex filenames, must be specified together --messages'
})
}

export const handler = (args: Arguments<InfuseOptions>): void => {
const targetPath = resolve(args.target)
const messagesPath = resolve(args.messages)
const messagesPath = resolve(args.locales)
const sources = readSFC(targetPath)
const messages = readLocaleMessages(messagesPath, args.match)
const meta = squeeze(targetPath, sources)
Expand Down
12 changes: 6 additions & 6 deletions test/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ exports[`infuse command output help 1`] = `
infuse locale messages to single-file components
Options:
--version Show version number [boolean]
--help Show help [boolean]
--target, -t target path that single-file components is stored
--version Show version number [boolean]
--help Show help [boolean]
--target, -t target path that single-file components is stored
[string] [required]
--messages, -m locale messages path to be infused [string] [required]
--match, -r option should be accepted a regex filenames, must be specified
together --messages [string]"
--locales, -l locale messages path to be infused [string] [required]
--match, -m option should be accepted a regex filenames, must be specified
together --messages [string]"
`;

exports[`squeeze command output help 1`] = `
Expand Down
6 changes: 3 additions & 3 deletions test/commands/infuse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test('absolute path', async () => {
const infuse = await import('../../src/commands/infuse')
const cmd = yargs.command(infuse)
const output = await new Promise(resolve => {
cmd.parse(`infuse --target=${TARGET_PATH}/src --messages=${TARGET_PATH}/locales.json`, () => {
cmd.parse(`infuse --target=${TARGET_PATH}/src --locales=${TARGET_PATH}/locales.json`, () => {
resolve(writeFiles)
})
})
Expand Down Expand Up @@ -120,7 +120,7 @@ test('relative path', async () => {
const infuse = await import('../../src/commands/infuse')
const cmd = yargs.command(infuse)
const output = await new Promise(resolve => {
cmd.parse(`infuse --target=./src --messages=locales-2.json`, () => {
cmd.parse(`infuse --target=./src --locales=locales-2.json`, () => {
resolve(writeFiles)
})
})
Expand Down Expand Up @@ -154,7 +154,7 @@ test('match option', async () => {
const infuse = await import('../../src/commands/infuse')
const cmd = yargs.command(infuse)
const output = await new Promise(resolve => {
cmd.parse(`infuse --target=./src --messages=./src/locales --match=^([\\w-]*)\\.json`, () => {
cmd.parse(`infuse --target=./src --locales=./src/locales --match=^([\\w-]*)\\.json`, () => {
resolve(writeFiles)
})
})
Expand Down

0 comments on commit ea812f3

Please sign in to comment.