1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-03 13:03:25 +03:00

Improve filepath equality (#170)

* improve filepath equality

* replace makeAbsolute by canonicalizePath
This commit is contained in:
janmasrovira 2022-06-15 12:38:24 +02:00 committed by GitHub
parent b7a0a3668b
commit 117020215c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ commandFirstFile CommandGlobalOptions {_cliGlobalOptions = GlobalOptions {..}} =
makeAbsPaths :: CLI -> IO CLI
makeAbsPaths cli = case cli of
Command cmd -> do
nOpts <- traverseOf globalInputFiles (mapM makeAbsolute) (cmd ^. cliGlobalOptions)
nOpts <- traverseOf globalInputFiles (mapM canonicalizePath) (cmd ^. cliGlobalOptions)
return (Command (set cliGlobalOptions nOpts cmd))
_ -> return cli

View File

@ -13,9 +13,9 @@ runFilesIO :: Member (Embed IO) r => Sem (Files ': r) a -> Sem r a
runFilesIO = interpret $ \case
ReadFile' f -> embed (readFile f)
EqualPaths' f h -> embed $ do
f' <- makeAbsolute f
h' <- makeAbsolute h
return (Just $ f' == h')
f' <- canonicalizePath f
h' <- canonicalizePath h
return (Just (equalFilePath f' h'))
runFilesEmpty :: Sem (Files ': r) a -> Sem r a
runFilesEmpty = runFilesPure mempty

View File

@ -32,7 +32,7 @@ testDescr PosTest {..} =
_testRoot = tRoot,
_testAssertion = Steps $ \step -> do
cwd <- getCurrentDirectory
entryFile <- makeAbsolute _file
entryFile <- canonicalizePath _file
let entryPoint = EntryPoint cwd False (pure entryFile)
step "Parsing"