diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/command/clean.lux | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index ecb71b59d..b966fe85e 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -4,6 +4,7 @@ ["." monad (#+ do)]] [control ["." try (#+ Try)] + ["." exception] [security ["!" capability]] [concurrency @@ -35,15 +36,23 @@ (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Any)) - (do {! ///action.monad} + (do promise.monad [#let [target (get@ #///.target profile)] root (: (Promise (Try (Directory Promise))) - (!.use (\ fs directory) target)) - _ (loop [root root] - (do ! - [_ (..clean_files! root) - subs (: (Promise (Try (List (Directory Promise)))) - (!.use (\ root directories) [])) - _ (monad.map ! recur subs)] - (!.use (\ root discard) [])))] - (console.write_line (..success target) console))) + (!.use (\ fs directory) target))] + (case root + (#try.Success root) + (do {! ///action.monad} + [_ (loop [root root] + (do ! + [_ (..clean_files! root) + subs (: (Promise (Try (List (Directory Promise)))) + (!.use (\ root directories) [])) + _ (monad.map ! recur subs)] + (!.use (\ root discard) [])))] + (console.write_line (..success target) console)) + + (#try.Failure error) + (if (exception.match? file.cannot_find_directory error) + (console.write_line (..success target) console) + (\ promise.monad wrap (#try.Failure error)))))) |