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
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