Commit def2aa01 authored by Michael Hanus's avatar Michael Hanus
Browse files

CPM updated

parent f431516f
...@@ -176,16 +176,20 @@ getLocalPackageSpec dir = ...@@ -176,16 +176,20 @@ getLocalPackageSpec dir =
--- Tries to find a package specification in the current directory or one of its --- Tries to find a package specification in the current directory or one of its
--- ancestors. Returns `Nothing` if there is not package specifiction. --- ancestors. Returns `Nothing` if there is not package specifiction.
--- In order to avoid infinite loops due to cyclic file structures,
--- the search is limited to 10 ancestor hierarchies.
searchLocalPackageSpec :: String -> IO (ErrorLogger (Maybe String)) searchLocalPackageSpec :: String -> IO (ErrorLogger (Maybe String))
searchLocalPackageSpec dir = do searchLocalPackageSpec = searchLocalSpec 10
where
searchLocalSpec m dir = do
existsLocal <- doesFileExist $ dir </> "package.json" existsLocal <- doesFileExist $ dir </> "package.json"
if existsLocal if existsLocal
then succeedIO (Just dir) then succeedIO (Just dir)
else log Debug ("No package.json in " ++ show dir ++ ", trying " ++ else log Debug ("No package.json in " ++ show dir ++ ", trying " ++
show (dir </> "..")) |> do show (dir </> "..")) |> do
parentExists <- doesDirectoryExist $ dir </> ".." parentExists <- doesDirectoryExist $ dir </> ".."
if parentExists if m>0 && parentExists
then searchLocalPackageSpec $ dir </> ".." then searchLocalSpec (m-1) $ dir </> ".."
else succeedIO Nothing else succeedIO Nothing
--- Resolves the dependencies for a package copy and fills the package caches. --- Resolves the dependencies for a package copy and fills the package caches.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment