1{-# OPTIONS_GHC -Wall #-}
23import qualified System.Directory as Dir
24import qualified System.Environment as Env
25import qualified System.FileLock as Lock
26import qualified System.FilePath as FP
27import System.FilePath ((</>), (<.>))
29import qualified Elm.ModuleName as ModuleName
30import qualified Elm.Package as Pkg
31import qualified Elm.Version as V
38stuff :: FilePath -> FilePath
40 root </> "elm-stuff" </> compilerVersion
43details :: FilePath -> FilePath
45 stuff root </> "d.dat"
48interfaces :: FilePath -> FilePath
50 stuff root </> "i.dat"
53objects :: FilePath -> FilePath
55 stuff root </> "o.dat"
58prepublishDir :: FilePath -> FilePath
60 stuff root </> "prepublish"
63compilerVersion :: FilePath
72elmi :: FilePath -> ModuleName.Raw -> FilePath
74 toArtifactPath root name "elmi"
77elmo :: FilePath -> ModuleName.Raw -> FilePath
79 toArtifactPath root name "elmo"
82toArtifactPath :: FilePath -> ModuleName.Raw -> String -> FilePath
83toArtifactPath root name ext =
84 stuff root </> ModuleName.toHyphenPath name <.> ext
91temp :: FilePath -> String -> FilePath
93 stuff root </> "temp" <.> ext
100findRoot :: IO (Maybe FilePath)
102 do dir <- Dir.getCurrentDirectory
103 findRootHelp (FP.splitDirectories dir)
106findRootHelp :: [String] -> IO (Maybe FilePath)
113 do exists <- Dir.doesFileExist (FP.joinPath dirs </> "elm.json")
115 then return (Just (FP.joinPath dirs))
116 else findRootHelp (init dirs)
123withRootLock :: FilePath -> IO a -> IO a
124withRootLock root work =
125 do let dir = stuff root
126 Dir.createDirectoryIfMissing True dir
127 Lock.withFileLock (dir </> "lock") Lock.Exclusive (\_ -> work)
130withRegistryLock :: PackageCache -> IO a -> IO a
131withRegistryLock (PackageCache dir) work =
132 Lock.withFileLock (dir </> "lock") Lock.Exclusive (\_ -> work)
139newtype PackageCache = PackageCache FilePath
142getPackageCache :: IO PackageCache
144 PackageCache <$> getCacheDir "packages"
147registry :: PackageCache -> FilePath
148registry (PackageCache dir) =
149 dir </> "registry.dat"
152package :: PackageCache -> Pkg.Name -> V.Version -> FilePath
153package (PackageCache dir) name version =
154 dir </> Pkg.toFilePath name </> V.toChars version
161getReplCache :: IO FilePath
166getCacheDir :: FilePath -> IO FilePath
167getCacheDir projectName =
168 do home <- getElmHome
169 let root = home </> compilerVersion </> projectName
170 Dir.createDirectoryIfMissing True root
174getElmHome :: IO FilePath
176 do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
177 case maybeCustomHome of
178 Just customHome -> return customHome
179 Nothing -> Dir.getAppUserDataDirectory "elm"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list