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
This commit is contained in:
Maximilian Tagher 2015-02-04 08:45:01 -08:00
parent 5d431fbdb5
commit 54cd923ed5

View File

@ -83,17 +83,19 @@ fixCabal name =
(spaces, x') = span isSpace x (spaces, x') = span isSpace x
fixRoutes :: String -> String -> String -> String -> String fixRoutes :: String -> String -> String -> String -> String
fixRoutes name pattern methods = fixRoutes name pattern methods fileContents =
(++ l) fileContents ++ l
where where
l = concat l = concat
[ pattern [ startingCharacter
, pattern
, " " , " "
, name , name
, "R " , "R "
, methods , methods
, "\n" , "\n"
] ]
startingCharacter = if "\n" `isSuffixOf` fileContents then "" else "\n"
mkHandler :: String -> String -> String -> String mkHandler :: String -> String -> String -> String
mkHandler name pattern methods = unlines mkHandler name pattern methods = unlines