From eae7b209389d1123ebf88288dfd93d514d6895a9 Mon Sep 17 00:00:00 2001 From: Martin Sosic Date: Mon, 5 Jul 2021 17:37:43 +0200 Subject: [PATCH] Replaced couple of last usages of Path with StrongPath. --- waspc/src/{Path => FilePath}/Extra.hs | 7 +------ waspc/src/Generator/ExternalCodeGenerator/Js.hs | 2 +- waspc/test/FilePath/ExtraTest.hs | 15 +++++++++++++++ waspc/test/Path/ExtraTest.hs | 15 --------------- 4 files changed, 17 insertions(+), 22 deletions(-) rename waspc/src/{Path => FilePath}/Extra.hs (80%) create mode 100644 waspc/test/FilePath/ExtraTest.hs delete mode 100644 waspc/test/Path/ExtraTest.hs diff --git a/waspc/src/Path/Extra.hs b/waspc/src/FilePath/Extra.hs similarity index 80% rename from waspc/src/Path/Extra.hs rename to waspc/src/FilePath/Extra.hs index 2c4ed8396..977872d38 100644 --- a/waspc/src/Path/Extra.hs +++ b/waspc/src/FilePath/Extra.hs @@ -1,11 +1,9 @@ -module Path.Extra +module FilePath.Extra ( reversePosixPath, - toPosixFilePath, ) where import Control.Exception (assert) -import Path import qualified System.FilePath.Posix as FPP -- | For given posix path P, returns posix path P', such that (terminal pseudocode incoming) @@ -22,6 +20,3 @@ reversePosixPath path where parts :: [String] parts = filter (/= ".") $ FPP.splitDirectories path - -toPosixFilePath :: Path Rel a -> FilePath -toPosixFilePath path = map (\c -> if c == '\\' then '/' else c) $ toFilePath path diff --git a/waspc/src/Generator/ExternalCodeGenerator/Js.hs b/waspc/src/Generator/ExternalCodeGenerator/Js.hs index f7f3e6bb3..d9b3a9d85 100644 --- a/waspc/src/Generator/ExternalCodeGenerator/Js.hs +++ b/waspc/src/Generator/ExternalCodeGenerator/Js.hs @@ -8,10 +8,10 @@ import Data.Maybe (fromJust) import Data.Text (Text, unpack) import qualified Data.Text as T import qualified ExternalCode as EC +import FilePath.Extra (reversePosixPath) import Generator.ExternalCodeGenerator.Common (GeneratedExternalCodeDir) import qualified Generator.ExternalCodeGenerator.Common as C import qualified Generator.FileDraft as FD -import Path.Extra (reversePosixPath) import StrongPath (Dir, File', Path', Rel, ()) import qualified StrongPath as SP import qualified Text.Regex.TDFA as TR diff --git a/waspc/test/FilePath/ExtraTest.hs b/waspc/test/FilePath/ExtraTest.hs new file mode 100644 index 000000000..3acc2b6ab --- /dev/null +++ b/waspc/test/FilePath/ExtraTest.hs @@ -0,0 +1,15 @@ +module FilePath.ExtraTest where + +import qualified FilePath.Extra as PE +import StrongPath (reldirP, toFilePath) +import Test.Tasty.Hspec + +spec_reversePosixPath :: Spec +spec_reversePosixPath = do + [reldirP|.|] ~> "." + [reldirP|foo|] ~> ".." + [reldirP|foo/bar|] ~> "../.." + [reldirP|./foo/bar/./test|] ~> "../../.." + where + path ~> expectedReversedPath = it (show path ++ " -> " ++ expectedReversedPath) $ do + PE.reversePosixPath (toFilePath path) `shouldBe` expectedReversedPath diff --git a/waspc/test/Path/ExtraTest.hs b/waspc/test/Path/ExtraTest.hs deleted file mode 100644 index 062471cf5..000000000 --- a/waspc/test/Path/ExtraTest.hs +++ /dev/null @@ -1,15 +0,0 @@ -module Path.ExtraTest where - -import Path (reldir) -import qualified Path.Extra as PE -import Test.Tasty.Hspec - -spec_reversePosixPath :: Spec -spec_reversePosixPath = do - [reldir|.|] ~> "." - [reldir|foo|] ~> ".." - [reldir|foo/bar|] ~> "../.." - [reldir|./foo/bar/./test|] ~> "../../.." - where - path ~> expectedReversedPath = it ((show path) ++ " -> " ++ expectedReversedPath) $ do - PE.reversePosixPath (PE.toPosixFilePath path) `shouldBe` expectedReversedPath