(.module: [lux #* [abstract ["." monad (#+ do)]] [control [try (#+ Try)] [concurrency ["." promise (#+ Promise)]]] [data [text ["%" format (#+ format)]]] [world ["." file (#+ Path)] ["." console (#+ Console)]]] ["." /// #_ [command (#+ Command)] ["#" profile] ["#." action (#+ Action)]]) (def: (clean_files! fs root) (-> (file.System Promise) Path (Promise (Try Any))) (let [! ///action.monad] (|> root (\ fs directory_files) (\ ! map (monad.map ! (\ fs delete))) (\ ! join)))) (def: #export success (-> ///.Target Text) (|>> (format "Successfully cleaned target directory: "))) (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Any)) (do {! promise.monad} [#let [target (get@ #///.target profile)] ? (\ fs directory? target) _ (let [! ///action.monad] (if ? (loop [root target] (do ! [_ (..clean_files! fs root) _ (|> root (\ fs sub_directories) (\ ! map (monad.map ! recur)) (\ ! join))] (\ fs delete root))) (\ ! wrap [])))] (console.write_line (..success target) console)))