@@ -138,7 +138,7 @@ travisFromConfigFile
138138travisFromConfigFile args opts path = do
139139 gitconfig <- liftIO readGitConfig
140140 cabalFiles <- getCabalFiles (optInputType' opts path) path
141- config' <- maybe ( return emptyConfig) readConfigFile (optConfig opts)
141+ config' <- findConfigFile (optConfig opts)
142142 let config = optConfigMorphism opts config'
143143 pkgs <- T. mapM (configFromCabalFile config) cabalFiles
144144 (ghcs, prj) <- case checkVersions (cfgTestedWith config) pkgs of
@@ -224,7 +224,7 @@ bashFromConfigFile
224224bashFromConfigFile args opts path = do
225225 gitconfig <- liftIO readGitConfig
226226 cabalFiles <- getCabalFiles (optInputType' opts path) path
227- config' <- maybe ( return emptyConfig) readConfigFile (optConfig opts)
227+ config' <- findConfigFile (optConfig opts)
228228 let config = optConfigMorphism opts config'
229229 pkgs <- T. mapM (configFromCabalFile config) cabalFiles
230230 (ghcs, prj) <- case checkVersions (cfgTestedWith config) pkgs of
@@ -311,7 +311,7 @@ githubFromConfigFile
311311githubFromConfigFile args opts path = do
312312 gitconfig <- liftIO readGitConfig
313313 cabalFiles <- getCabalFiles (optInputType' opts path) path
314- config' <- maybe ( return emptyConfig) readConfigFile (optConfig opts)
314+ config' <- findConfigFile (optConfig opts)
315315 let config = optConfigMorphism opts config'
316316 pkgs <- T. mapM (configFromCabalFile config) cabalFiles
317317 (ghcs, prj) <- case checkVersions (cfgTestedWith config) pkgs of
@@ -367,6 +367,20 @@ regenerateGitHub opts = do
367367 noGitHubScript :: IO ()
368368 noGitHubScript = putStrLn $ " No " ++ fp ++ " , skipping GitHub config regeneration"
369369
370+ -------------------------------------------------------------------------------
371+ -- Config file
372+ -------------------------------------------------------------------------------
373+
374+ findConfigFile :: MonadIO m => ConfigOpt -> m Config
375+ findConfigFile ConfigOptNo = return emptyConfig
376+ findConfigFile (ConfigOpt fp) = readConfigFile fp
377+ findConfigFile ConfigOptAuto = do
378+ let defaultPath = " cabal.haskell-ci"
379+ exists <- liftIO (doesFileExist defaultPath)
380+ if exists
381+ then readConfigFile defaultPath
382+ else return emptyConfig
383+
370384-------------------------------------------------------------------------------
371385-- Patches
372386-------------------------------------------------------------------------------
0 commit comments