mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-26 22:36:01 +03:00
Replaced couple of last usages of Path with StrongPath.
This commit is contained in:
parent
3bae54c3e8
commit
eae7b20938
@ -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
|
@ -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
|
||||
|
15
waspc/test/FilePath/ExtraTest.hs
Normal file
15
waspc/test/FilePath/ExtraTest.hs
Normal file
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user