From 54cd923ed53ac793dcd0a9cb26412af7e3a2c221 Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Wed, 4 Feb 2015 08:45:01 -0800 Subject: [PATCH] Fix add-handler putting two routes on one line * If there is a new line at the end of the file, add the route as normal * If there isn't, add a newline character before the route * Closes #921 --- yesod-bin/AddHandler.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yesod-bin/AddHandler.hs b/yesod-bin/AddHandler.hs index 3561b525..1d6d15cc 100644 --- a/yesod-bin/AddHandler.hs +++ b/yesod-bin/AddHandler.hs @@ -83,17 +83,19 @@ fixCabal name = (spaces, x') = span isSpace x fixRoutes :: String -> String -> String -> String -> String -fixRoutes name pattern methods = - (++ l) +fixRoutes name pattern methods fileContents = + fileContents ++ l where l = concat - [ pattern + [ startingCharacter + , pattern , " " , name , "R " , methods , "\n" ] + startingCharacter = if "\n" `isSuffixOf` fileContents then "" else "\n" mkHandler :: String -> String -> String -> String mkHandler name pattern methods = unlines