packages feed

language-docker 6.0.0 → 6.0.1

raw patch · 5 files changed

+26/−7 lines, 5 files

Files

language-docker.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 1258a921f9de776fdbf9c4b99356869a65eeade549a9d206b7319c93bd5c4af8+-- hash: dcb1ee69fa5273343e855a6671c943851c7dfe672278f892ef306e15a0362a21  name:           language-docker-version:        6.0.0+version:        6.0.1 synopsis:       Dockerfile parser, pretty-printer and embedded DSL description:    All functions for parsing, printing and writting Dockerfiles are exported through @Language.Docker@. For more fine-grained operations look for specific modules that implement a certain functionality.                 See the <https://github.com/hadolint/language-docker GitHub project> for the source-code and examples.
src/Language/Docker.hs view
@@ -6,7 +6,7 @@     , Text.Megaparsec.parseErrorPretty       -- * Pretty-printing Dockerfiles (@Language.Docker.PrettyPrint@)     , prettyPrint-    , prettyPrintInstructionPos+    , prettyPrintDockerfile       -- * Writting Dockerfiles (@Language.Docker.EDSL@)     , Language.Docker.EDSL.toDockerfileText     , Language.Docker.EDSL.toDockerfile
src/Language/Docker/Normalize.hs view
@@ -50,7 +50,7 @@     -- and we return 'Nothing' as an indication that this line does not form part of the     -- final result.     transform :: NormalizedLine -> Text -> (NormalizedLine, Maybe Text)-    transform (Joined prev times) line+    transform (Joined prev times) rawLine         -- If we are buffering lines and the next one is empty or it starts with a comment         -- we simply ignore the comment and remember to add a newline         | Text.null line || isComment line = (Joined prev (times + 1), Nothing)@@ -61,12 +61,16 @@         -- the concatanation of the buffer and the current line as result, after padding with         -- newlines         | otherwise = (Continue, Just (toText (prev <> Builder.fromText line <> padNewlines times)))+      where+        line = Text.stripEnd rawLine     -- When not buffering lines, then we just check if we need to start doing it by checking     -- whether or not the current line ends with \. If it does not, then we just yield the     -- current line as part of the result-    transform Continue l-        | endsWithEscape l = (Joined (normalizeLast l) 1, Nothing)-        | otherwise = (Continue, Just l)+    transform Continue rawLine+        | endsWithEscape line = (Joined (normalizeLast line) 1, Nothing)+        | otherwise = (Continue, Just line)+      where+        line = Text.stripEnd rawLine     --     endsWithEscape t         | Text.null t = False
src/Language/Docker/Parser.hs view
@@ -5,6 +5,9 @@ module Language.Docker.Parser     ( parseText     , parseFile+    , Parser+    , Error+    , DockerfileError(..)     ) where  import Control.Monad (void)
test/Language/Docker/ParserSpec.hs view
@@ -234,10 +234,12 @@                                                    , "ENV NODE_VERSION=v5.7.1 DEBIAN_FRONTEND=noninteractive\n"                                                    ]                 in normalizeEscapedLines dockerfile `shouldBe` normalizedDockerfile+             it "join escaped lines" $                 let dockerfile = Text.unlines ["ENV foo=bar \\", "baz=foz"]                     normalizedDockerfile = Text.unlines ["ENV foo=bar baz=foz", ""]                 in normalizeEscapedLines dockerfile `shouldBe` normalizedDockerfile+             it "join long CMD" $                 let longEscapedCmd =                         Text.unlines@@ -260,6 +262,16 @@                             , "\n"                             ]                 in normalizeEscapedLines longEscapedCmd `shouldBe` longEscapedCmdExpected++            it "tolerates spaces after a newline escape" $+                let dockerfile = Text.unlines [ "FROM busy\\     "+                                              , "box"+                                              , "RUN echo\\    "+                                              , " hello"+                                              ]+                in assertAst dockerfile [ From (UntaggedImage "busybox" Nothing)+                                        , Run "echo hello"+                                        ]         describe "expose" $ do             it "should handle number ports" $                 let content = "EXPOSE 8080"