1{-# OPTIONS_GHC -Wall #-}
22import qualified System.Directory as Dir
23import qualified System.Environment as Env
24import qualified System.FileLock as Lock
25import qualified System.FilePath as FP
26import System.FilePath ((</>), (<.>))
28import qualified Elm.ModuleName as ModuleName
29import qualified Elm.Package as Pkg
30import qualified Elm.Version as V
37stuff :: FilePath -> FilePath
39 root </> "elm-stuff" </> compilerVersion
42details :: FilePath -> FilePath
44 stuff root </> "d.dat"
47interfaces :: FilePath -> FilePath
49 stuff root </> "i.dat"
52objects :: FilePath -> FilePath
54 stuff root </> "o.dat"
57prepublishDir :: FilePath -> FilePath
59 stuff root </> "prepublish"
62compilerVersion :: FilePath
71elmi :: FilePath -> ModuleName.Raw -> FilePath
73 toArtifactPath root name "elmi"
76elmo :: FilePath -> ModuleName.Raw -> FilePath
78 toArtifactPath root name "elmo"
81toArtifactPath :: FilePath -> ModuleName.Raw -> String -> FilePath
82toArtifactPath root name ext =
83 stuff root </> ModuleName.toHyphenPath name <.> ext
90temp :: FilePath -> String -> FilePath
92 stuff root </> "temp" <.> ext
99findRoot :: IO (Maybe FilePath)
101 do dir <- Dir.getCurrentDirectory
102 findRootHelp (FP.splitDirectories dir)
105findRootHelp :: [String] -> IO (Maybe FilePath)
112 do exists <- Dir.doesFileExist (FP.joinPath dirs </> "elm.json")
114 then return (Just (FP.joinPath dirs))
115 else findRootHelp (init dirs)
122withRootLock :: FilePath -> IO a -> IO a
123withRootLock root work =
124 do let dir = stuff root
125 Dir.createDirectoryIfMissing True dir
126 Lock.withFileLock (dir </> "project.lock") Lock.Exclusive (\_ -> work)
133newtype PackageCache = PackageCache FilePath
136getPackageCache :: IO PackageCache
138 PackageCache <$> getCacheDir "packages"
141registry :: PackageCache -> FilePath
142registry (PackageCache dir) =
143 dir </> "registry.dat"
146package :: PackageCache -> Pkg.Name -> V.Version -> FilePath
147package (PackageCache dir) name version =
148 dir </> Pkg.toFilePath name </> V.toChars version
155getReplCache :: IO FilePath
160getCacheDir :: FilePath -> IO FilePath
161getCacheDir projectName =
162 do home <- getElmHome
163 let root = home </> compilerVersion </> projectName
164 Dir.createDirectoryIfMissing True root
168getElmHome :: IO FilePath
170 do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
171 case maybeCustomHome of
172 Just customHome -> return customHome
173 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