diff --git a/yesod-bin/AddHandler.hs b/yesod-bin/AddHandler.hs index 8bbad758..0721f94e 100644 --- a/yesod-bin/AddHandler.hs +++ b/yesod-bin/AddHandler.hs @@ -120,9 +120,20 @@ fixApp name = | otherwise = x : go xs fixCabal :: String -> String -> String -fixCabal name = - unlines . reverse . go . reverse . lines +fixCabal name orig = + unlines $ (reverse $ go $ reverse libraryLines) ++ restLines where + origLines = lines orig + + (libraryLines, restLines) = break isExeTestBench origLines + + isExeTestBench x = any + (\prefix -> prefix `isPrefixOf` x) + [ "executable" + , "test-suite" + , "benchmark" + ] + l = " Handler." ++ name go [] = [l] diff --git a/yesod-bin/ChangeLog.md b/yesod-bin/ChangeLog.md index 33bd9f04..87f29749 100644 --- a/yesod-bin/ChangeLog.md +++ b/yesod-bin/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.4.18.3 + +* Adding a new handler adds it under wrong stanza [#1273](https://github.com/yesodweb/yesod/issues/1273) + ## 1.4.18.2 * Work around change in behavior in newer optparse-applicative ([mailing list discussion](https://groups.google.com/d/msg/yesodweb/BrTkMKFREgU/AKVc9AK2AQAJ)) diff --git a/yesod-bin/yesod-bin.cabal b/yesod-bin/yesod-bin.cabal index bf8ef4f3..fca3a229 100644 --- a/yesod-bin/yesod-bin.cabal +++ b/yesod-bin/yesod-bin.cabal @@ -1,5 +1,5 @@ name: yesod-bin -version: 1.4.18.2 +version: 1.4.18.3 license: MIT license-file: LICENSE author: Michael Snoyman