File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,8 +205,8 @@ applyTemplate project template nonceParams dir templateText = do
205205 throwM (InvalidTemplate template (show e)))
206206 when (M. null files) $
207207 throwM (InvalidTemplate template " Template does not contain any files" )
208- unless (any (" .cabal" `isSuffixOf` ) . M. keys $ files) $
209- throwM (InvalidTemplate template " Template does not contain a .cabal\
208+ unless (any (\ x -> or [ " .cabal" `isSuffixOf` x, x == " package.yaml " ] ) . M. keys $ files) $
209+ throwM (InvalidTemplate template " Template does not contain a .cabal or `package.yaml` \
210210 \ file" )
211211 liftM
212212 M. fromList
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ module Stack.Package
2121 ,readPackageUnresolvedBS
2222 ,resolvePackage
2323 ,findOrGenerateCabalFile
24+ ,hpack
2425 ,Package (.. )
2526 ,GetPackageFiles (.. )
2627 ,GetPackageOpts (.. )
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ import Prelude
5252import Stack.BuildPlan
5353import Stack.Constants (stackDotYaml )
5454import Stack.Package (printCabalFileWarning
55+ , hpack
5556 , readPackageUnresolved )
5657import Stack.Setup
5758import Stack.Setup.Installed
@@ -468,12 +469,20 @@ checkResolverSpec gpds flags resolver = do
468469 -- TODO support custom resolver for stack init
469470 ResolverCustom {} -> return $ BuildPlanCheckPartial Map. empty Map. empty
470471
471- -- | Finds all files with a .cabal extension under a given directory.
472+ -- | Finds all files with a .cabal extension under a given directory. If
473+ -- a `hpack` `package.yaml` file exists, this will be used to generate a cabal
474+ -- file.
472475-- Subdirectories can be included depending on the @recurse@ parameter.
473476findCabalFiles :: MonadIO m => Bool -> Path Abs Dir -> m [Path Abs File ]
474- findCabalFiles recurse dir =
475- liftIO $ findFiles dir isCabal (\ subdir -> recurse && not (isIgnored subdir))
477+ findCabalFiles recurse dir = do
478+ hpackFiles <- liftIO $ findFiles dir isHpack dirFilter
479+ liftIO $ do
480+ forM_ hpackFiles (hpack . parent)
481+ findFiles dir isCabal dirFilter
476482 where
483+ isHpack = (== " package.yaml" ) . toFilePath . filename
484+
485+ dirFilter subdir = recurse && not (isIgnored subdir)
477486 isCabal path = " .cabal" `isSuffixOf` toFilePath path
478487
479488 isIgnored path = FP. dropTrailingPathSeparator (toFilePath (dirname path))
You can’t perform that action at this time.
0 commit comments