Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ os:
- osx
install:
- npm install --global esy
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then npm install --global reason-cli@3.1.0-linux; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm install --global reason-cli@3.1.0-darwin; fi
- esy install
script:
- esy build
Expand Down
21 changes: 7 additions & 14 deletions bin/Extract.re
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,19 @@ let iterator =

let extractMessages = ast => iterator.structure(iterator, Obj.magic(ast));

let readMessagesFromChannel = channel =>
switch (Ast_io.from_channel(channel)) {
| Result.Ok((_, Ast_io.Impl((module Version), ast))) =>
module Convert = Convert(Version, OCaml_406);
let converted = Obj.magic(Convert.copy_structure(ast));
extractMessages(converted);
| Result.Ok((_, Ast_io.Intf(_, _))) => Printf.eprintf("Interface AST not supported, only implementation AST\n")
| Result.Error(Not_a_binary_ast(_)) => Printf.eprintf("Error: input is not a binary AST\n")
| Result.Error(Unknown_version(v)) => Printf.eprintf("Error: unknown AST version: %s\n", v)
};

let processReasonFile = filename => {
let channel = Unix.open_process_in("refmt -p binary " ++ filename);
readMessagesFromChannel(channel);
Unix.close_process_in(channel) |> ignore;
let channel = open_in_bin(filename);
let lexbuf = Lexing.from_channel(channel);
let ast = Reason_toolchain.RE.implementation(lexbuf);
close_in(channel);
extractMessages(ast);
};

let rec processDirectory = dir =>
Sys.readdir(dir)
|> Array.iter(filename => {
let path = Filename.concat(dir, filename);

if (Sys.is_directory(path)) {
processDirectory(path);
} else if (Filename.extension(filename) == ".re") {
Expand All @@ -55,6 +47,7 @@ let outputJson = () => {
|> List.map(((_id, message)) => message)
|> List.sort(Message.compare)
|> List.map(Message.toJson);

Yojson.Basic.pretty_to_channel(stdout, `List(sortedJsonObjects));
print_newline();
};
Expand Down
234 changes: 20 additions & 214 deletions esy.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
((name lib)
(flags (-w -40 -w +26))
(public_name bs-react-intl-extractor)
(libraries (ocaml-migrate-parsetree yojson unix))))
(libraries (reason yojson unix))))
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
},
"dependencies": {
"@esy-ocaml/esy-installer": "^0.0.0",
"@esy-ocaml/reason": "^3.2.0",
"@opam/jbuilder": "^1.0.0-beta14",
"@opam/ocaml-migrate-parsetree": "^1.0.10",
"@opam/reason": "^3.0.0",
"@opam/yojson": "^1.4.1",
"refmterr": "^3.0.4"
},
Expand Down