mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-27 02:52:22 +03:00
17 lines
618 B
Haskell
17 lines
618 B
Haskell
|
module Test.Util
|
||
|
( posixToSystemFp
|
||
|
) where
|
||
|
|
||
|
import qualified Path as P
|
||
|
import qualified System.FilePath as FP
|
||
|
|
||
|
import Fixtures (fpRoot)
|
||
|
|
||
|
-- | Takes posix path and converts it into windows path if running on Windows or leaves as it is if on Unix.
|
||
|
posixToSystemFp :: FilePath -> FilePath
|
||
|
posixToSystemFp posixFp = maybeSystemRoot ++ systemFpRootless
|
||
|
where
|
||
|
maybeSystemRoot = if head posixFp == '/' then P.toFilePath fpRoot else ""
|
||
|
posixFpRootless = if head posixFp == '/' then tail posixFp else posixFp
|
||
|
systemFpRootless = map (\c -> if c == '/' then FP.pathSeparator else c) posixFpRootless
|