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)
122withProjectLock :: FilePath -> IO a -> IO a
123withProjectLock root work =
124 do let dir = stuff root
125 Dir.createDirectoryIfMissing True dir
126 Lock.withFileLock (dir </> "project.lock") Lock.Exclusive (\_ -> work)
129withCacheLock :: PackageCache -> IO a -> IO a
130withCacheLock (PackageCache dir) work =
131 Lock.withFileLock (dir </> "cache.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