Skip to content

Commit

Permalink
Release v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDegraeve committed Sep 26, 2020
1 parent bafefe9 commit 662676c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion esy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-intl-auto-id-ppx",
"version": "2.0.0",
"version": "2.0.1",
"description": "Reason/OCaml PPX generating ReactIntl `id` from `defaultMessage`",
"author": "Simon Degraeve <simon.degraeve@gmail.com>",
"license": "MIT",
Expand Down
14 changes: 9 additions & 5 deletions lib/react_intl_auto_id_ppx.re
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ let hasIntlAttribute = (items: structure) => {
items
|> List.exists(item =>
switch (item) {
| {pstr_desc: Pstr_attribute(({txt: "intl.messages", _}, PStr([])))} =>
| {
pstr_desc: Pstr_attribute(({txt: "intl.messages", _}, PStr([]))),
_,
} =>
true
| _ => false
}
Expand Down Expand Up @@ -93,8 +96,8 @@ let extractMessageFromRecord = fields => {
|> List.iter(assoc =>
switch (assoc) {
| (
{txt: Lident(key)},
{pexp_desc: Pexp_constant(Pconst_string(value, _))},
{txt: Lident(key), _},
{pexp_desc: Pexp_constant(Pconst_string(value, _)), _},
) =>
map := map^ |> StringMap.add(key, value)
| _ => ()
Expand Down Expand Up @@ -157,9 +160,10 @@ let structure = (mapper, structure) =>
|> List.map(valueBinding =>
switch (valueBinding) {
| {
pvb_pat: {ppat_desc: Ppat_var(_)} as pattern,
pvb_pat: {ppat_desc: Ppat_var(_), _} as pattern,
pvb_expr:
{pexp_desc: Pexp_record(fields, None)} as expr,
{pexp_desc: Pexp_record(fields, None), _} as expr,
_,
} =>
let map = extractMessageFromRecord(fields);
let defaultMessage =
Expand Down

0 comments on commit 662676c

Please sign in to comment.