Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate a period as first character in prefix #64

Merged
merged 3 commits into from
Feb 10, 2019

Conversation

kuma-kuma
Copy link
Contributor

What:
複数階層のディレクトリを prefix から削除するテストを追加しました(ref #63 )。
テストを追加した際、removePrefix オプションによって prefix が exportName だけになると、prefix の先頭にピリオドがつく bug (下記参照)を見つけたので修正しました

// test case
{
  title: 'removePrefix = "src.__fixtures__", includeExportName = true',
  tests: [multiExportTest],
  pluginOptions: {
    removePrefix: 'src.__fixtures__',
    includeExportName: true,
  },
}

// result
import { defineMessages } from 'react-intl'

export const extra = defineMessages({
  hello: 'hello world extra'
})

export default defineMessages({
  hello: 'hello world',
})

           

import { defineMessages } from 'react-intl';

export const extra = defineMessages({
  hello: {
    "id": ".extra.hello", // <-- prefix の先頭にピリオドが生成される
    "defaultMessage": 'hello world extra'
  }
});

export default defineMessages({
  hello: {
    "id": "hello",
    "defaultMessage": 'hello world'
  }
});

Why:
想定される動作ではないと思うので修正しました

How:
テストを追加しました
src/index.js の getPrefix メソッドで 「exportName が存在するかつ prefix が exportName のみの場合」 exportName だけを return するようにしました

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

return fixed
}

if (fixed === '') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@akameco akameco merged commit 383b6de into akameco:master Feb 10, 2019
@akameco
Copy link
Owner

akameco commented Feb 10, 2019

@kuma-kuma ありがとうございます 👍

@akameco
Copy link
Owner

akameco commented Feb 10, 2019

修正を入れたバージョンをv1.6.1としてReleaseしました

@kuma-kuma kuma-kuma deleted the fix/remove-prefix branch February 10, 2019 23:45
@kuma-kuma
Copy link
Contributor Author

ありがとうございます 👍

こちらこそ、便利プラグイン公開してくれてありがとうございます
このプラグインめっちゃ助かってます、、、!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants