diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-03-31 20:16:18 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2019-03-31 20:16:18 +0200 |
commit | 6d5ced6d2490793680f2b4344d102769774f3a87 (patch) | |
tree | a2be7994ffaf023c50f172d933383488e43d791a | |
parent | 6e75b7853bd761db302dc629b8ee4f087a18b0d6 (diff) |
Fix replaceVersionDecl for Cabal HEAD
It breaks when there's a `cabal-version:` delaration in the file.
-rw-r--r-- | src/CabalHelper/Compiletime/Cabal.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/CabalHelper/Compiletime/Cabal.hs b/src/CabalHelper/Compiletime/Cabal.hs index d1c6c1d..0a11ba3 100644 --- a/src/CabalHelper/Compiletime/Cabal.hs +++ b/src/CabalHelper/Compiletime/Cabal.hs @@ -217,7 +217,9 @@ unpackCabalHEAD tmpdir = do -- | Replace the version declaration in a cabal file replaceVersionDecl :: (Version -> Maybe Version) -> String -> Maybe String replaceVersionDecl ver_fn cf = let - Just (before_ver,m) = find (\(_i,t) -> "version:" `isPrefixOf` t) $ splits cf + isVersionDecl ([],t) = "version:" `isPrefixOf` t + isVersionDecl (i,t) = "\n" `isSuffixOf` i && "version:" `isPrefixOf` t + Just (before_ver,m) = find isVersionDecl $ splits cf Just (ver_decl,after_ver) = find (\s -> case s of (_i,'\n':x:_) -> not $ isSpace x; _ -> False) $ filter (\(_i,t) -> "\n" `isPrefixOf` t) |