Browse Source

mad_hooks: log every line of hook output as it goes

Vlad Ki 6 years ago
parent
commit
387ab63573
2 changed files with 6 additions and 6 deletions
  1. 1 1
      rebar.config
  2. 5 5
      src/mad_hooks.erl

+ 1 - 1
rebar.config

@@ -1,3 +1,3 @@
 {deps_dir,"deps"}.
 {erl_opts,[nowarn_export_all]}.
-{deps,[{sh,".*",{git,"git://github.com/synrc/sh",{tag,"2.11"}}}]}.
+{deps,[{sh,".*",{git,"git://github.com/synrc/sh",{branch, "master"}}}]}.

+ 5 - 5
src/mad_hooks.erl

@@ -115,11 +115,11 @@ sh(Command, Hook, Dir, Env) ->
             {env, Env}
         ]
     ),
-    {done, Status, Out} = sh:sh_loop(Port, binary),
+    {done, Status, _} = sh:sh_loop(Port, fun(Chunk, _) -> io:format("~s", [Chunk]), [] end, []),
     case Status of
         0 ->
-            mad:info("~s~n", [Out]);
+            ok;
         _ ->
-            mad:info("Failed hook for ~p with ~s~n", [Command, Out]),
-            exit({error, Out})
-    end.
+            mad:info("Failed hook for ~p~n", [Command]),
+            exit({error, Status})
+    end.