on cb359fa help sign in
elk/builder/src/Stuff/Paths.hs
92 lines 1.5 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Stuff.Paths
3 ( docs
4 , summary
5 , prepublishDir
6 , removeStuff
7 , elmi
8 , elmo
9 , moduleDocs
10 , temp
11 )
12 where
15import Control.Monad.Trans (liftIO)
16import qualified System.Directory as Dir
17import System.FilePath ((</>), (<.>))
19import qualified Elm.ModuleName as ModuleName
20import qualified Elm.Version as V
21import qualified Reporting.Task as Task
25-- PATHS
28stuff :: FilePath
29stuff =
30 "elm-stuff" </> V.toChars V.compiler
33docs :: FilePath
34docs =
35 stuff </> "docs.json"
38summary :: FilePath
39summary =
40 stuff </> "summary.dat"
43prepublishDir :: FilePath
44prepublishDir =
45 stuff </> "prepublish"
49-- REMOVE STUFF
52removeStuff :: FilePath -> Task.Task_ e ()
53removeStuff root =
54 liftIO $
55 do let dir = root </> "elm-stuff"
56 exists <- Dir.doesDirectoryExist dir
57 if exists
58 then Dir.removeDirectoryRecursive dir
59 else return ()
63-- ELMI and ELMO
66elmi :: FilePath -> ModuleName.Raw -> FilePath
67elmi root name =
68 toArtifactPath root name "elmi"
71elmo :: FilePath -> ModuleName.Raw -> FilePath
72elmo root name =
73 toArtifactPath root name "elmo"
76moduleDocs :: FilePath -> ModuleName.Raw -> FilePath
77moduleDocs root name =
78 toArtifactPath root name "json"
81toArtifactPath :: FilePath -> ModuleName.Raw -> String -> FilePath
82toArtifactPath root name ext =
83 root </> stuff </> ModuleName.nameToHyphenPath name <.> ext
87-- TEMP
90temp :: String -> FilePath
91temp ext =
92 stuff </> "temp" <.> ext