on master help sign in
Merge pull request #571 from obsidiansystems/jb-ignore-package-environment

Ignore package environment files in `ob run` and `ob repl`

commitf90ed2e325d1ce07f5e3f06e58c466897c736f58 authorElliot Cameron <3noch@users.noreply.github.com> dateMon 16 Dec 2019, 09:23 (7 years ago) parent6421c44bdfa340
2 files changed+12−3
ChangeLog.md+1 lib/command/src/Obelisk/Command/Run.hs+11−3
ChangeLog.md+1
@@ -18,6 +18,7 @@ This project's release branch is `master`. This log is written from the perspect
1818 version. As a result, you no longer need to have ghcid installed to
1919 use `ob run`, as we provide one for you.
2020* `ob` commands now complain less on systems with umasks other than `0022`.
21+* Ignore package environment files in `ob run` and `ob repl`
2122
2223## v0.2.0.0 - 2019-8-17
2324
lib/command/src/Obelisk/Command/Run.hs+11−3
@@ -219,7 +219,7 @@ runGhciRepl
219219 :: MonadObelisk m
220220 => FilePath -- ^ Path to .ghci
221221 -> m ()
222−runGhciRepl dotGhci = inProjectShell "ghc" $ unwords $ "ghci" : ["-no-user-package-db", "-ghci-script", dotGhci]
222+runGhciRepl dotGhci = inProjectShell "ghc" $ "ghci " <> makeBaseGhciOptions dotGhci
223223
224224-- | Run ghcid
225225runGhcid
@@ -232,12 +232,20 @@ runGhcid dotGhci mcmd = callCommand $ unwords $ $(staticWhich "ghcid") : opts
232232 opts =
233233 [ "-W"
234234 --TODO: The decision of whether to use -fwarn-redundant-constraints should probably be made by the user
235− , "--command='ghci -Wall -ignore-dot-ghci -fwarn-redundant-constraints -no-user-package-db -ghci-script " <> dotGhci <> "' "
235+ , "--command='ghci -Wall -ignore-dot-ghci -fwarn-redundant-constraints " <> makeBaseGhciOptions dotGhci <> "' "
236236 , "--reload=config"
237237 , "--outputfile=ghcid-output.txt"
238238 ] <> testCmd
239239 testCmd = maybeToList (flip fmap mcmd $ \cmd -> "--test='" <> cmd <> "'")
240240
241+makeBaseGhciOptions :: FilePath -> String
242+makeBaseGhciOptions dotGhci =
243+ unwords
244+ [ "-no-user-package-db"
245+ , "-package-env -"
246+ , "-ghci-script " <> dotGhci
247+ ]
248+
241249getFreePort :: MonadIO m => m PortNumber
242250getFreePort = liftIO $ withSocketsDo $ do
243251 addr:_ <- getAddrInfo (Just defaultHints) (Just "127.0.0.1") (Just "0")
@@ -246,4 +254,4 @@ getFreePort = liftIO $ withSocketsDo $ do
246254 open addr = do
247255 sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
248256 bind sock (addrAddress addr)
249− return sock
257+ return sock