implicit-hie 0.1.1.0 → 0.1.2.0
raw patch · 6 files changed
+41/−11 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- app/Main.hs +18/−7
- implicit-hie.cabal +1/−1
- src/Hie/Cabal/Parser.hs +3/−2
- src/Hie/Locate.hs +1/−1
- src/Hie/Yaml.hs +1/−0
- test/Spec.hs +17/−0
app/Main.hs view
@@ -15,17 +15,12 @@ import System.Directory import System.Directory.Internal import System.FilePath.Posix+import System.Environment main :: IO () main = do pwd <- getCurrentDirectory- files <- listDirectory pwd- let name =- if | any (("dist-newstyle" ==) . takeFileName) files -> "cabal"- | any ((".stack-work" ==) . takeFileName) files -> "stack"- | any (("cabal.project" ==) . takeFileName) files -> "cabal"- | any (("stack.yaml" ==) . takeFileName) files -> "stack"- | otherwise -> "cabal"+ name <- resolveName pwd cfs <- runMaybeT $ case name of "cabal" -> cabalPkgs pwd _ -> stackYamlPkgs pwd@@ -35,3 +30,19 @@ <> "\n You may need to run stack build." pkgs <- catMaybes <$> mapM (nestedPkg pwd) (concat cfs) putStr <$> hieYaml name $ fmtPkgs name pkgs++resolveName :: FilePath -> IO String+resolveName pwd = do+ args <- getArgs+ files <- listDirectory pwd+ let fileNames = map takeFileName files+ name =+ if | "--cabal" `elem` args -> "cabal"+ | "--stack" `elem` args -> "stack"+ | "dist-newstyle" `elem` fileNames -> "cabal"+ | ".stack-work" `elem` fileNames -> "stack"+ | "cabal.project" `elem` fileNames -> "cabal"+ | "stack.yaml" `elem` fileNames -> "stack"+ | otherwise -> "cabal"+ return name+
implicit-hie.cabal view
@@ -7,7 +7,7 @@ -- hash: b2b829a658e33ea328c725dea732391089d03ffd2a216d413a75d88aefa7c181 name: implicit-hie-version: 0.1.1.0+version: 0.1.2.0 description: Auto generate a stack or cabal multi component hie.yaml file category: Development, Tools, Hie, HLS synopsis: Auto generate hie-bios cradles & hie.yaml
src/Hie/Cabal/Parser.hs view
@@ -121,9 +121,10 @@ <|> (skipBlockLine i >> pathMain i p m o a) <|> pure ( map (<//> m) p- <> [ p' <//> (o' <> ".hs")+ <> [ p' <//> (o'' <> ".hs") | p' <- p,- o' <- filter (`notElem` a) o+ o' <- filter (`notElem` a) o,+ let o'' = T.replace "." "/" o' ] )
src/Hie/Locate.hs view
@@ -31,7 +31,7 @@ deriving (Eq, Ord) instance FromJSON Pkgs where- parseJSON (Object v) = Pkgs <$> v .: "packages"+ parseJSON (Object v) = Pkgs <$> v .:? "packages" .!= ["."] parseJSON _ = fail "could not read packages from stack.yaml" stackYamlPkgs :: FilePath -> MaybeT IO [FilePath]
src/Hie/Yaml.hs view
@@ -50,6 +50,7 @@ <> "component: " <> dQuote c +-- | Same as init but handle empty list without throwing errors. dropLast :: [a] -> [a] dropLast l = take (length l - 1) l
test/Spec.hs view
@@ -90,6 +90,13 @@ $ it "list with leading commas" $ ("one\n , two\n , three3" :: Text) ~> parseList 1 `shouldParse` ["one", "two", "three3"]+ describe "Should Succeed"+ $ it "succesfully parses exe component with other-modules containing dots"+ $ exeSection2 ~> parseExe 0 + `shouldParse` [ Comp Exe "gen-hie" "app/Main.hs"+ , Comp Exe "gen-hie" "app/Hie/Executable/Helper.hs"+ , Comp Exe "gen-hie" "app/Hie/Executable/Utils.hs"+ ] exeSection :: Text exeSection =@@ -175,3 +182,13 @@ \ , text\n\ \ default-language: Haskell2010\n\ \"++exeSection2 :: Text+exeSection2 =+ "executable gen-hie\n\+ \ other-modules:\n\+ \ Hie.Executable.Helper\n\+ \ Hie.Executable.Utils\n\+ \ hs-source-dirs:\n\+ \ app\n\+ \ main-is: Main.hs \n"