Skip to content

Commit bfc0d04

Browse files
committed
Don't provide "-ghci-script" for --no-load #1360
1 parent e8a325f commit bfc0d04

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/Stack/Ghci.hs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,38 +94,38 @@ ghci GhciOpts{..} = do
9494
(if null pkgs then [] else ["-hide-all-packages"]) ++
9595
nubOrd (concatMap (concatMap (bioGeneratedOpts . snd) . ghciPkgOpts) pkgs) ++
9696
concatMap (concatMap (bioGhcOpts . snd) . ghciPkgOpts) pkgs
97-
modulesToLoad
98-
| ghciNoLoadModules = []
99-
| otherwise =
100-
nubOrd
101-
(maybe [] (return . toFilePath) mainFile <>
102-
concatMap (map display . S.toList . ghciPkgModules) pkgs)
97+
modulesToLoad = nubOrd $
98+
maybe [] (return . toFilePath) mainFile <>
99+
concatMap (map display . S.toList . ghciPkgModules) pkgs
103100
odir =
104101
[ "-odir=" <> toFilePathNoTrailingSep (objectInterfaceDir bconfig)
105102
, "-hidir=" <> toFilePathNoTrailingSep (objectInterfaceDir bconfig)]
106103
$logInfo
107104
("Configuring GHCi with the following packages: " <>
108105
T.intercalate ", " (map (packageNameText . ghciPkgName) pkgs))
109-
tmp <- liftIO getTemporaryDirectory
110-
withCanonicalizedTempDirectory
111-
tmp
112-
"ghci-script"
113-
(\tmpDir ->
114-
do let scriptPath = tmpDir </> $(mkRelFile "ghci-script")
115-
fp = toFilePath scriptPath
116-
loadModules = ":load " <> unwords modulesToLoad
117-
bringIntoScope = ":module + " <> unwords modulesToLoad
118-
liftIO (writeFile fp (unlines [loadModules,bringIntoScope]))
119-
finally (exec
120-
defaultEnvSettings
121-
(fromMaybe (compilerExeName wc) ghciGhcCommand)
122-
("--interactive" :
123-
-- This initial "-i" resets the include directories to not
124-
-- include CWD.
125-
"-i" :
126-
odir <> pkgopts <> ghciArgs <>
127-
["-ghci-script=" <> fp]))
128-
(removeFile scriptPath))
106+
let execGhci extras =
107+
exec defaultEnvSettings
108+
(fromMaybe (compilerExeName wc) ghciGhcCommand)
109+
("--interactive" :
110+
-- This initial "-i" resets the include directories to not
111+
-- include CWD.
112+
"-i" :
113+
odir <> pkgopts <> ghciArgs <> extras)
114+
case ghciNoLoadModules of
115+
True -> execGhci []
116+
False -> do
117+
tmp <- liftIO getTemporaryDirectory
118+
withCanonicalizedTempDirectory
119+
tmp
120+
"ghci-script"
121+
(\tmpDir ->
122+
do let scriptPath = tmpDir </> $(mkRelFile "ghci-script")
123+
fp = toFilePath scriptPath
124+
loadModules = ":load " <> unwords modulesToLoad
125+
bringIntoScope = ":module + " <> unwords modulesToLoad
126+
liftIO (writeFile fp (unlines [loadModules,bringIntoScope]))
127+
finally (execGhci ["-ghci-script=" <> fp])
128+
(removeFile scriptPath))
129129

130130
-- | Figure out the main-is file to load based on the targets. Sometimes there
131131
-- is none, sometimes it's unambiguous, sometimes it's

0 commit comments

Comments
 (0)