From e1af5374ba4d969f866867db47af7ecf60cc9933 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 15 Jan 2022 02:17:35 -0400 Subject: Fixed a logging/reporting issue for Lux/JS. --- stdlib/source/program/aedifex/command/build.lux | 1 + stdlib/source/program/compositor.lux | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 15a671615..ba461d461 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -202,6 +202,7 @@ ... But it's written this way because the more straightforward way (i.e. by using (try.with async.monad)) ... eventually led to the function hanging/freezing. ... I'm not sure why it happened, but I got this weirder implementation to work. + ... TODO: Improve this implementation. (let [[read! write!] (: [(Async (Try Any)) (async.Resolver (Try Any))] (async.async [])) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 54fc903ad..2b6850cf8 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -22,9 +22,8 @@ ["[0]" instant]] ["[0]" world "_" ["[0]" file] - ["[1]/[0]" program] - ... ["[0]" console] - ] + ["[0]" console] + ["[1]/[0]" program]] [tool [compiler ["[0]" phase] @@ -59,14 +58,23 @@ (def: (or_crash! failure_description action) (All (_ a) (-> Text (Async (Try a)) (Async a))) - (do async.monad + (do [! async.monad] [?output action] (case ?output {try.#Failure error} - (exec (debug.log! (format text.new_line - failure_description text.new_line - error text.new_line)) - (io.run! (# world/program.default exit +1))) + (let [report (format text.new_line + failure_description text.new_line + error text.new_line)] + (do ! + [_ (with_expansions [ (in (debug.log! report))] + (for [@.js (case console.default + {.#None} + + + {.#Some console} + (console.write_line report console))] + ))] + (io.run! (# world/program.default exit +1)))) {try.#Success output} (in output)))) -- cgit v1.2.3