Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 55c0096

Browse files
committed
Add reading RTS options for psc from argv
1 parent 31e1be2 commit 55c0096

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

src/GulpPurescript/Options.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ pscBundleOptions opts = fold <$> parsed
256256
opt outputOpt a.output <>
257257
opt moduleOpt a."module" <>
258258
opt mainOpt a.main <>
259-
opt namespaceOpt a.namespace
259+
opt namespaceOpt a.namespace <>
260+
opt requirePathOpt a.requirePath
260261

261262
pscDocsOptions :: Foreign -> Either ForeignError (Array String)
262263
pscDocsOptions opts = fold <$> parsed

src/GulpPurescript/Plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
var cwd = process.cwd();
66

77
exports.cwd = cwd;
8+
exports.argv = process.argv;

src/GulpPurescript/Plugin.purs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ import Control.Monad.Eff.Class (liftEff)
1616
import Control.Monad.Eff.Exception (Error())
1717
import Control.Monad.Error.Class (catchError, throwError)
1818

19-
import Data.Array (concat)
19+
import Data.Array as A
2020
import Data.Either (Either(..), either)
2121
import Data.Foreign (Foreign())
22-
import Data.Foreign.Class (IsForeign, read, readProp)
22+
import Data.Foreign.Class (read)
2323
import Data.Foreign.NullOrUndefined (runNullOrUndefined)
24-
import Data.Maybe (Maybe(Just), maybe, fromMaybe)
24+
import Data.Maybe (Maybe(..), maybe, fromMaybe)
2525
import Data.String (joinWith, null)
2626
import Data.Tuple (Tuple(..))
2727
import Data.Tuple.Nested (tuple2)
2828

29-
import GulpPurescript.Buffer (Buffer(), mkBufferFromString)
29+
import GulpPurescript.Buffer (mkBufferFromString)
3030
import GulpPurescript.ChildProcess (ChildProcess(), spawn)
3131
import GulpPurescript.Glob (Glob(), globAll)
3232
import GulpPurescript.GulpUtil (File(), mkFile, mkPluginError)
@@ -39,6 +39,15 @@ import GulpPurescript.ResolveBin (ResolveBin(), resolveBin)
3939
import GulpPurescript.Stream (Stream(), ReadableStream(), mkReadableStreamFromAff)
4040
import GulpPurescript.Which (Which(), which)
4141

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+
4251
type Effects eff =
4352
( cp :: ChildProcess
4453
, glob :: Glob
@@ -55,20 +64,28 @@ type Errorback eff = Error -> Eff (Effects eff) Unit
5564

5665
type Callback eff a = a -> Eff (Effects eff) Unit
5766

67+
nodeCommand :: String
5868
nodeCommand = "node"
5969

70+
pursPackage :: String
6071
pursPackage = "purescript"
6172

73+
psciFilename :: String
6274
psciFilename = ".psci"
6375

76+
psciLoadModuleCommand :: String
6477
psciLoadModuleCommand = ":m"
6578

79+
psciLoadForeignCommand :: String
6680
psciLoadForeignCommand = ":f"
6781

82+
pscCommand :: String
6883
pscCommand = "psc"
6984

85+
pscBundleCommand :: String
7086
pscBundleCommand = "psc-bundle"
7187

88+
pscDocsCommand :: String
7289
pscDocsCommand = "psc-docs"
7390

7491
foreign import cwd :: String
@@ -103,7 +120,7 @@ execute cmd args = do
103120
psc :: forall eff. Foreign -> Eff (Effects eff) (ReadableStream Unit)
104121
psc opts = mkReadableStreamFromAff $ do
105122
output <- either (throwPluginError <<< show)
106-
(execute pscCommand)
123+
(execute pscCommand <<< (<> rtsOpts))
107124
(pscOptions opts)
108125
if null output
109126
then pure unit
@@ -131,7 +148,7 @@ psci opts = mkReadableStreamFromAff (either (throwPluginError <<< show) run (rea
131148
srcs <- globAll (either pure id a.src)
132149
ffis <- globAll (either pure id (fromMaybe (Right []) (runNullOrUndefined a.ffi)))
133150

134-
let lines = (loadModule <$> concat srcs) <> (loadForeign <$> concat ffis)
151+
let lines = (loadModule <$> A.concat srcs) <> (loadForeign <$> A.concat ffis)
135152
buffer = mkBufferFromString (joinWith "\n" lines)
136153

137154
return (mkFile psciFilename buffer)

0 commit comments

Comments
 (0)