diff --git a/cgtools.cabal b/cgtools.cabal index c38f5da..93a85b8 100644 --- a/cgtools.cabal +++ b/cgtools.cabal @@ -48,6 +48,7 @@ executable cgtools , bytestring , ansi-terminal , hastache + , FindBin main-is: Main.hs -- from Tasty cabal with ansi-terminal @@ -82,6 +83,7 @@ library , bytestring , ansi-terminal , hastache + , FindBin -- from Tasty cabal with ansi-terminal cpp-options: -DCOLORS diff --git a/src/CGTools/Install.hs b/src/CGTools/Install.hs index 617e068..c67561d 100644 --- a/src/CGTools/Install.hs +++ b/src/CGTools/Install.hs @@ -13,6 +13,7 @@ import Text.Hastache.Context (mkGenericContext) import Data.Data (Data, Typeable) import Paths_cgtools import System.IO (hFlush, stdout) +import System.Environment.FindBin (getProgPath) data Ctx = Ctx { path :: Text @@ -20,13 +21,14 @@ data Ctx = Ctx { runInstall :: IO () runInstall = do + bin <- getProgPath + let binPath = pack $ bin ++ "/cgtools" + let context = mkGenericContext Ctx { path = binPath } g <- getGitPath let commitHook = getPrepareCommitPath (pack g) genFile context "prepare-commit-msg" commitHook p <- getPermissions commitHook setPermissions commitHook (p {executable = True}) - where - context = mkGenericContext Ctx { path = "./cgtools" } getGitPath :: IO String getGitPath = readProcess "git" [ "rev-parse", "--git-dir" ] ""