Skip to content

Commit

Permalink
fixed double imports from ControllerGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Laobiz committed Aug 17, 2020
1 parent d31e931 commit 5378f5c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions IHP/IDE/CodeGen/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ addImport file importStatement = do
content :: Text <- Text.readFile (cs file)
case addImport' content importStatement of
Just newContent -> Text.writeFile (cs file) (cs newContent)
Nothing -> putStrLn ("Could not automatically add " <> tshow importStatement <> " to " <> file)
Nothing -> pure ()
pure ()

addImport' :: Text -> Text -> Maybe Text
addImport' file importStatement =
if importStatement `isSuffixOf` file
addImport' content importStatement = do
if importStatement `isInfixOf` content
then Nothing
else appendLineAfter file ("import" `isPrefixOf`) [importStatement]
else appendLineAfter content ("import" `isPrefixOf`) [importStatement]

addAction :: Text -> [Text] -> IO ()
addAction filePath fileContent = do
Expand Down

0 comments on commit 5378f5c

Please sign in to comment.