Skip to content

Commit

Permalink
Move configPathRelative to top-level for re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Feb 13, 2022
1 parent 90cbaa5 commit d367f79
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/amazonka/src/Amazonka/Auth/ConfigFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,13 @@ fromFileEnv env = liftIO $ do
conf <- configPathRelative "/.aws/config"

fromFilePath (maybe "default" Text.pack mProfile) cred conf env

configPathRelative :: String -> IO String
configPathRelative p = handling_ _IOException err dir
where
configPathRelative p = handling_ _IOException err dir
where
err = Exception.throwIO $ MissingFileError ("$HOME" ++ p)
dir = case os of
"mingw32" ->
Environment.lookupEnv "USERPROFILE"
>>= maybe (Exception.throwIO $ MissingFileError "%USERPROFILE%") pure
_ -> Directory.getHomeDirectory <&> (++ p)
err = Exception.throwIO $ MissingFileError ("$HOME" ++ p)
dir = case os of
"mingw32" ->
Environment.lookupEnv "USERPROFILE"
>>= maybe (Exception.throwIO $ MissingFileError "%USERPROFILE%") pure
_ -> Directory.getHomeDirectory <&> (++ p)

0 comments on commit d367f79

Please sign in to comment.