1
- module Main (main ) where
1
+ module Main (main , mainInParentDirectory ) where
2
2
3
3
import ClassyPrelude
4
4
import qualified System.Process as Process
@@ -30,9 +30,25 @@ import qualified IHP.FrameworkConfig as FrameworkConfig
30
30
import qualified Control.Concurrent.Chan.Unagi as Queue
31
31
import IHP.IDE.FileWatcher
32
32
import qualified System.Environment as Env
33
+ import qualified System.Directory as Directory
34
+
35
+ mainInParentDirectory :: IO ()
36
+ mainInParentDirectory = do
37
+ cwd <- Directory. getCurrentDirectory
38
+ let projectDir = cwd <> " /../"
39
+ Directory. setCurrentDirectory projectDir
40
+
41
+ Env. setEnv " IHP_LIB" (cwd <> " /ihp-ide/lib/IHP" )
42
+ Env. setEnv " TOOLSERVER_STATIC" (cwd <> " /ihp-ide/lib/IHP/static" )
43
+ Env. setEnv " IHP_STATIC" (cwd <> " /lib/IHP/static" )
44
+
45
+ mainWithOptions True
33
46
34
47
main :: IO ()
35
- main = withUtf8 do
48
+ main = mainWithOptions False
49
+
50
+ mainWithOptions :: Bool -> IO ()
51
+ mainWithOptions wrapWithDirenv = withUtf8 do
36
52
actionVar <- newEmptyMVar
37
53
appStateRef <- emptyAppState >>= newIORef
38
54
portConfig <- findAvailablePortConfig
@@ -45,7 +61,7 @@ main = withUtf8 do
45
61
logger <- Log. newLogger def
46
62
(ghciInChan, ghciOutChan) <- Queue. newChan
47
63
liveReloadClients <- newIORef mempty
48
- let ? context = Context { actionVar, portConfig, appStateRef, isDebugMode, logger, ghciInChan, ghciOutChan, liveReloadClients }
64
+ let ? context = Context { actionVar, portConfig, appStateRef, isDebugMode, logger, ghciInChan, ghciOutChan, liveReloadClients, wrapWithDirenv }
49
65
50
66
-- Print IHP Version when in debug mode
51
67
when isDebugMode (Log. debug (" IHP Version: " <> Version. ihpVersion))
@@ -215,7 +231,7 @@ startOrWaitPostgres = do
215
231
startPostgres
216
232
pure ()
217
233
218
- startGHCI :: IO ManagedProcess
234
+ startGHCI :: ( ? context :: Context ) => IO ManagedProcess
219
235
startGHCI = do
220
236
let args =
221
237
[ " -threaded"
@@ -227,7 +243,8 @@ startGHCI = do
227
243
, " -ghci-script" , " .ghci" -- Because the previous line ignored default ghci config file locations, we have to manual load our .ghci
228
244
, " +RTS" , " -A128m" , " -n2m" , " -H2m" , " --nonmoving-gc" , " -N"
229
245
]
230
- createManagedProcess (Process. proc " ghci" args)
246
+
247
+ createManagedProcess (procDirenvAware " ghci" args)
231
248
{ Process. std_in = Process. CreatePipe
232
249
, Process. std_out = Process. CreatePipe
233
250
, Process. std_err = Process. CreatePipe
0 commit comments