@@ -16,17 +16,17 @@ import Control.Monad.Eff.Class (liftEff)
16
16
import Control.Monad.Eff.Exception (Error ())
17
17
import Control.Monad.Error.Class (catchError , throwError )
18
18
19
- import Data.Array ( concat )
19
+ import Data.Array as A
20
20
import Data.Either (Either (..), either )
21
21
import Data.Foreign (Foreign ())
22
- import Data.Foreign.Class (IsForeign , read , readProp )
22
+ import Data.Foreign.Class (read )
23
23
import Data.Foreign.NullOrUndefined (runNullOrUndefined )
24
- import Data.Maybe (Maybe (Just ), maybe , fromMaybe )
24
+ import Data.Maybe (Maybe (.. ), maybe , fromMaybe )
25
25
import Data.String (joinWith , null )
26
26
import Data.Tuple (Tuple (..))
27
27
import Data.Tuple.Nested (tuple2 )
28
28
29
- import GulpPurescript.Buffer (Buffer (), mkBufferFromString )
29
+ import GulpPurescript.Buffer (mkBufferFromString )
30
30
import GulpPurescript.ChildProcess (ChildProcess (), spawn )
31
31
import GulpPurescript.Glob (Glob (), globAll )
32
32
import GulpPurescript.GulpUtil (File (), mkFile , mkPluginError )
@@ -39,6 +39,15 @@ import GulpPurescript.ResolveBin (ResolveBin(), resolveBin)
39
39
import GulpPurescript.Stream (Stream (), ReadableStream (), mkReadableStreamFromAff )
40
40
import GulpPurescript.Which (Which (), which )
41
41
42
+ foreign import argv :: Array String
43
+
44
+ rtsOpts :: Array String
45
+ rtsOpts =
46
+ let startIndex = A .elemIndex " --psc-rts-flags" argv
47
+ in case startIndex of
48
+ Just i -> [" +RTS" ] <> A .drop (i + 1 ) argv <> [" -RTS" ]
49
+ _ -> []
50
+
42
51
type Effects eff =
43
52
( cp :: ChildProcess
44
53
, glob :: Glob
@@ -55,20 +64,28 @@ type Errorback eff = Error -> Eff (Effects eff) Unit
55
64
56
65
type Callback eff a = a -> Eff (Effects eff ) Unit
57
66
67
+ nodeCommand :: String
58
68
nodeCommand = " node"
59
69
70
+ pursPackage :: String
60
71
pursPackage = " purescript"
61
72
73
+ psciFilename :: String
62
74
psciFilename = " .psci"
63
75
76
+ psciLoadModuleCommand :: String
64
77
psciLoadModuleCommand = " :m"
65
78
79
+ psciLoadForeignCommand :: String
66
80
psciLoadForeignCommand = " :f"
67
81
82
+ pscCommand :: String
68
83
pscCommand = " psc"
69
84
85
+ pscBundleCommand :: String
70
86
pscBundleCommand = " psc-bundle"
71
87
88
+ pscDocsCommand :: String
72
89
pscDocsCommand = " psc-docs"
73
90
74
91
foreign import cwd :: String
@@ -103,7 +120,7 @@ execute cmd args = do
103
120
psc :: forall eff . Foreign -> Eff (Effects eff ) (ReadableStream Unit )
104
121
psc opts = mkReadableStreamFromAff $ do
105
122
output <- either (throwPluginError <<< show)
106
- (execute pscCommand)
123
+ (execute pscCommand <<< (<> rtsOpts) )
107
124
(pscOptions opts)
108
125
if null output
109
126
then pure unit
@@ -131,7 +148,7 @@ psci opts = mkReadableStreamFromAff (either (throwPluginError <<< show) run (rea
131
148
srcs <- globAll (either pure id a.src)
132
149
ffis <- globAll (either pure id (fromMaybe (Right [] ) (runNullOrUndefined a.ffi)))
133
150
134
- let lines = (loadModule <$> concat srcs) <> (loadForeign <$> concat ffis)
151
+ let lines = (loadModule <$> A . concat srcs) <> (loadForeign <$> A . concat ffis)
135
152
buffer = mkBufferFromString (joinWith " \n " lines)
136
153
137
154
return (mkFile psciFilename buffer)
0 commit comments