-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathSetup.hs
More file actions
21 lines (19 loc) · 861 Bytes
/
Copy pathSetup.hs
File metadata and controls
21 lines (19 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import Distribution.PackageDescription (emptyHookedBuildInfo)
import Distribution.Simple
import System.Directory (copyFile, doesFileExist)
import System.Exit
import System.Process (readProcessWithExitCode)
main =
defaultMainWithHooks
simpleUserHooks{preBuild = preBuildChecks}
where
-- \| Checks that Imagemagick and LaTeX are available
preBuildChecks _ _ = do
mapM_ checkDependency ["magick", "pdflatex"]
return emptyHookedBuildInfo
checkDependency :: String -> IO ()
checkDependency dependency = do
(result, _, _) <- readProcessWithExitCode dependency ["-version"] ""
case result of
ExitFailure 127 -> putStrLn ("Error Message: " ++ dependency ++ " is NOT available. Please ensure it is on your path.") >> exitFailure
_ -> putStrLn (dependency ++ " has been installed.")