@@ -62,49 +62,57 @@ type Task a = Task.Task Exit.Make a
64run :: [FilePath] -> Flags -> IO ()
64run :: [FilePath] -> Flags -> IO ()
65−run paths (Flags debug optimize maybeOutput report maybeDocs) =
65+run paths flags@(Flags _ _ _ report _) =
66 do style <- getStyle report
66 do style <- getStyle report
67+ maybeRoot <- Stuff.findRoot
67− Reporting.attemptWithStyle style Exit.makeToReport $ Task.run $
68+ Reporting.attemptWithStyle style Exit.makeToReport $
68− do root <- Task.mio Exit.MakeNoOutline Stuff.findRoot
69+ case maybeRoot of
70+ Just root -> runHelp root paths style flags
71+ Nothing -> return $ Left $ Exit.MakeNoOutline
74+runHelp :: FilePath -> [FilePath] -> Reporting.Style -> Flags -> IO (Either Exit.Make ())
75+runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) =
76+ Stuff.withRootLock root $ Task.run $
69− desiredMode <- getMode debug optimize
77+ do desiredMode <- getMode debug optimize
70− details <- Task.eio Exit.MakeBadDetails (Details.load style root)
78+ details <- Task.eio Exit.MakeBadDetails (Details.load style root)
71− case paths of
79+ case paths of
73− do exposed <- getExposed details
81+ do exposed <- getExposed details
74− buildExposed style root details maybeDocs exposed
82+ buildExposed style root details maybeDocs exposed
77− do artifacts <- buildPaths style root details (NE.List p ps)
85+ do artifacts <- buildPaths style root details (NE.List p ps)
78− case maybeOutput of
86+ case maybeOutput of
79− Nothing ->
87+ Nothing ->
80− case getMains artifacts of
88+ case getMains artifacts of
82− return ()
90+ return ()
84− [name] ->
92+ [name] ->
85− do builder <- toBuilder root details desiredMode artifacts
93+ do builder <- toBuilder root details desiredMode artifacts
86− generate style "index.html" (Html.sandwich name builder) (NE.List name [])
94+ generate style "index.html" (Html.sandwich name builder) (NE.List name [])
88− name:names ->
96+ name:names ->
89− do builder <- toBuilder root details desiredMode artifacts
97+ do builder <- toBuilder root details desiredMode artifacts
90− generate style "elm.js" builder (NE.List name names)
98+ generate style "elm.js" builder (NE.List name names)
92− Just DevNull ->
100+ Just DevNull ->
93− return ()
101+ return ()
95− Just (JS target) ->
103+ Just (JS target) ->
96− case getNoMains artifacts of
104+ case getNoMains artifacts of
98− do builder <- toBuilder root details desiredMode artifacts
106+ do builder <- toBuilder root details desiredMode artifacts
99− generate style target builder (Build.getMainNames artifacts)
107+ generate style target builder (Build.getMainNames artifacts)
101− name:names ->
109+ name:names ->
102− Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
110+ Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
104− Just (Html target) ->
112+ Just (Html target) ->
105− do name <- hasOneMain artifacts
113+ do name <- hasOneMain artifacts
106− builder <- toBuilder root details desiredMode artifacts
114+ builder <- toBuilder root details desiredMode artifacts
107− generate style target (Html.sandwich name builder) (NE.List name [])
115+ generate style target (Html.sandwich name builder) (NE.List name [])