Skip to content

Fix purs command problem for Windows #141

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ getReverseDeps db dep =
innerDeps <- getReverseDeps db packageName
return $ pair : innerDeps

getPursPath :: IO Text
getPursPath = do
bin <- which "purs" -- *nix binary
exe <- which "purs.exe" -- windows binary (maybe it putted directly on the PATH)
cmd <- which "purs.cmd" -- windows binary wrapper (maybe it built with npm)
let purs = bin <|> exe <|> cmd
case purs of
Nothing -> exitWithErr "The \"purs\" executable could not be found. Please make sure your PATH variable is set correctly"
Just p -> return $ pathToTextUnsafe p

getTransitiveDeps :: PackageSet -> [PackageName] -> IO [(PackageName, PackageInfo)]
getTransitiveDeps db deps =
Map.toList . fold <$> traverse (go Set.empty) deps
Expand Down Expand Up @@ -266,7 +276,8 @@ installImpl config@PackageConfig{ depends } limitJobs = do

getPureScriptVersion :: IO Version
getPureScriptVersion = do
let pursProc = inproc "purs" [ "--version" ] empty
pursPath <- getPursPath
let pursProc = inproc pursPath [ "--version" ] empty
outputLines <- shellToIOText pursProc
case outputLines of
[onlyLine]
Expand Down Expand Up @@ -391,13 +402,15 @@ exec execNames onlyDeps passthroughOptions limitJobs = do
pkg <- readPackageFile
installImpl pkg limitJobs

pursPath <- getPursPath
paths <- getPaths
let cmdParts = tail execNames
let cmdName = head execNames
cmdParts = tail execNames
srcParts = [ "src" </> "**" </> "*.purs" | not onlyDeps ]
exit
=<< Process.waitForProcess
=<< Process.runProcess
(head execNames)
(if cmdName == "purs" then T.unpack pursPath else cmdName)
(cmdParts <> passthroughOptions
<> map Path.encodeString (srcParts <> paths))
Nothing -- no special path to the working dir
Expand Down Expand Up @@ -526,7 +539,8 @@ verify arg limitJobs = do
sem <- newQSem max'
mapConcurrently (bracket_ (waitQSem sem) (signalQSem sem) . dirFor) dependencies
let srcGlobs = map (pathToTextUnsafe . (</> ("src" </> "**" </> "*.purs"))) dirs
procs "purs" ("compile" : srcGlobs) empty
pursPath <- getPursPath
procs pursPath ("compile" : srcGlobs) empty

formatPackageFile :: IO ()
formatPackageFile =
Expand Down