diff options
author | Björn Gustavsson <bgustavsson@gmail.com> | 2021-11-24 15:30:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 08:30:34 -0600 |
commit | 12d27b59b7340104b01de68c23bd21900ea8eae1 (patch) | |
tree | 8214bbfad5644a097f1ec6db6bf0a5b07abe3a61 /lib/compilers/erlang.js | |
parent | 555edcad31a6018ed6997488802a50941c6d6d2d (diff) | |
download | compiler-explorer-12d27b59b7340104b01de68c23bd21900ea8eae1.tar.gz compiler-explorer-12d27b59b7340104b01de68c23bd21900ea8eae1.zip |
Format the output file for Erlang in a nicer way (#3135)gh-1306
For Erlang, format the output in the same way as the 'S' option
does. To achieve this, we use the `beam_listing` module, which is
undocumented but has been stable for many many years.
Diffstat (limited to 'lib/compilers/erlang.js')
-rw-r--r-- | lib/compilers/erlang.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/compilers/erlang.js b/lib/compilers/erlang.js index aa9ebde3f..31018086c 100644 --- a/lib/compilers/erlang.js +++ b/lib/compilers/erlang.js @@ -39,8 +39,9 @@ export class ErlangCompiler extends BaseCompiler { '-eval', '{ok, Input} = init:get_argument(input),' + '{ok, _, Output} = compile:file(Input, [\'S\', binary, no_line_info, report]),' + - 'Binary = io_lib:format("~p", [Output]),' + - `file:write_file("${outputFilename}", list_to_binary(Binary)),` + + `{ok,Fd} = file:open("${outputFilename}", [write]),` + + 'beam_listing:module(Fd, Output),' + + 'file:close(Fd),' + 'halt().', ]; } |