1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-07 13:05:39 +03:00

Abort more gracefully if the source files don't exist

Fixes #59.
This commit is contained in:
Michael Peyton Jones 2019-05-23 19:00:35 +01:00
parent 5d9e3a5f7d
commit 3891f80bf5
No known key found for this signature in database
GPG Key ID: 86A43C24A728F66D

View File

@ -58,6 +58,9 @@ newtype Sources = Sources
getSources :: IO Sources
getSources = do
exists <- Dir.doesFileExist pathNixSourcesJson
unless exists abortSourcesDoesntExist
warnIfOutdated
-- TODO: if doesn't exist: run niv init
putStrLn $ "Reading sources file"
@ -696,6 +699,14 @@ Make sure the repository exists.
-- Abort
-------------------------------------------------------------------------------
abortSourcesDoesntExist :: IO a
abortSourcesDoesntExist = abort $ unlines [ line1, line2 ]
where
line1 = "Cannot use " <> pathNixSourcesJson
line2 = [s|
The sources file does not exist! You may need to run 'niv init'.
|]
abortSourcesIsntAMap :: IO a
abortSourcesIsntAMap = abort $ unlines [ line1, line2 ]
where