@@ -58,8 +58,9 @@ import Commands as C
58import Parser
58import Parser
60data PSCiOptions = PSCiOptions
60data PSCiOptions = PSCiOptions
61− { psciMultiLineMode :: Bool
61+ { psciMultiLineMode :: Bool
62 , psciInputFile :: [FilePath]
62 , psciInputFile :: [FilePath]
63+ , psciInputNodeFlags :: [String]
@@ -73,6 +74,7 @@ data PSCiState = PSCiState
73 , psciImportedModuleNames :: [P.ModuleName]
74 , psciImportedModuleNames :: [P.ModuleName]
74 , psciLoadedModules :: [(Either P.RebuildPolicy FilePath, P.Module)]
75 , psciLoadedModules :: [(Either P.RebuildPolicy FilePath, P.Module)]
75 , psciLetBindings :: [P.Declaration]
76 , psciLetBindings :: [P.Declaration]
77+ , psciNodeFlags :: [String]
78-- State helpers
80-- State helpers
@@ -401,13 +403,14 @@ handleDeclaration :: P.Expr -> PSCI ()
401handleDeclaration val = do
403handleDeclaration val = do
402 st <- PSCI $ lift get
404 st <- PSCI $ lift get
403 let m = createTemporaryModule True st val
405 let m = createTemporaryModule True st val
406+ let nodeArgs = psciNodeFlags st ++ [indexFile]
404 e <- psciIO . runMake $ P.make modulesDir (psciLoadedModules st ++ [(Left P.RebuildAlways, m)]) []
407 e <- psciIO . runMake $ P.make modulesDir (psciLoadedModules st ++ [(Left P.RebuildAlways, m)]) []
405 case e of
408 case e of
406 Left err -> PSCI $ outputStrLn err
409 Left err -> PSCI $ outputStrLn err
407 Right _ -> do
410 Right _ -> do
408 psciIO $ writeFile indexFile "require('$PSCI').main();"
411 psciIO $ writeFile indexFile "require('$PSCI').main();"
409 process <- psciIO findNodeProcess
412 process <- psciIO findNodeProcess
410− result <- psciIO $ traverse (\node -> readProcessWithExitCode node [indexFile] "") process
413+ result <- psciIO $ traverse (\node -> readProcessWithExitCode node nodeArgs "") process
411 case result of
414 case result of
412 Just (ExitSuccess, out, _) -> PSCI $ outputStrLn out
415 Just (ExitSuccess, out, _) -> PSCI $ outputStrLn out
413 Just (ExitFailure _, _, err) -> PSCI $ outputStrLn err
416 Just (ExitFailure _, _, err) -> PSCI $ outputStrLn err
@@ -608,7 +611,7 @@ loop PSCiOptions{..} = do
608 Right modules -> do
611 Right modules -> do
609 historyFilename <- getHistoryFilename
612 historyFilename <- getHistoryFilename
610 let settings = defaultSettings { historyFile = Just historyFilename }
613 let settings = defaultSettings { historyFile = Just historyFilename }
611− flip evalStateT (PSCiState psciInputFile defaultImports modules []) . runInputT (setComplete completion settings) $ do
614+ flip evalStateT (PSCiState psciInputFile defaultImports modules [] psciInputNodeFlags) . runInputT (setComplete completion settings) $ do
612 outputStrLn prologueMessage
615 outputStrLn prologueMessage
613 traverse_ (mapM_ (runPSCI . handleCommand)) config
616 traverse_ (mapM_ (runPSCI . handleCommand)) config
@@ -633,9 +636,18 @@ inputFile = strArgument $
633 metavar "FILE"
636 metavar "FILE"
634 <> Opts.help "Optional .purs files to load on start"
637 <> Opts.help "Optional .purs files to load on start"
639+nodeFlagsFlag :: Parser [String]
640+nodeFlagsFlag = option parser $
642+ <> metavar "NODE_OPTS"
643+ <> Opts.help "Flags to pass to node, separated by spaces"
645+ parser = words <$> str
636psciOptions :: Parser PSCiOptions
647psciOptions :: Parser PSCiOptions
637psciOptions = PSCiOptions <$> multiLineMode
648psciOptions = PSCiOptions <$> multiLineMode
638 <*> many inputFile
649 <*> many inputFile
640main :: IO ()
652main :: IO ()
641main = execParser opts >>= loop
653main = execParser opts >>= loop