Yeah
This commit is contained in:
@@ -159,15 +159,15 @@ createRegularFileFd fm dest =
|
||||
FD.openFd (toFilePath dest) WriteOnly [oExcl] (Just fm)
|
||||
|
||||
|
||||
exe :: ByteString
|
||||
-> [ByteString]
|
||||
-> Bool
|
||||
-> Maybe (Path Abs)
|
||||
-> IO (Either ProcessError ())
|
||||
exe exe' args spath chdir = do
|
||||
exec :: ByteString -- ^ thing to execute
|
||||
-> [ByteString] -- ^ args for the thing
|
||||
-> Bool -- ^ whether to search PATH for the thing
|
||||
-> Maybe (Path Abs) -- ^ optionally chdir into this
|
||||
-> IO (Either ProcessError ())
|
||||
exec exe args spath chdir = do
|
||||
pid <- SPPB.forkProcess $ do
|
||||
maybe (pure ()) (changeWorkingDirectory . toFilePath) chdir
|
||||
SPPB.executeFile exe' spath args Nothing
|
||||
SPPB.executeFile exe spath args Nothing
|
||||
|
||||
fmap toProcessError $ SPPB.getProcessStatus True True pid
|
||||
|
||||
@@ -179,4 +179,3 @@ toProcessError mps = case mps of
|
||||
Just (Terminated _ _ ) -> Left $ PTerminated
|
||||
Just (Stopped _ ) -> Left $ PStopped
|
||||
Nothing -> Left $ NoSuchPid
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
module GHCup.Types where
|
||||
|
||||
import Data.Map.Strict ( Map )
|
||||
import Network.URL
|
||||
import qualified GHC.Generics as GHC
|
||||
import Data.Versions
|
||||
import URI.ByteString
|
||||
|
||||
|
||||
data Tool = GHC
|
||||
@@ -55,7 +55,7 @@ data PlatformRequest = PlatformRequest {
|
||||
, _rVersion :: Maybe Versioning
|
||||
} deriving (Eq, Show)
|
||||
|
||||
type PlatformVersionSpec = Map (Maybe Versioning) URL
|
||||
type PlatformVersionSpec = Map (Maybe Versioning) URI
|
||||
type PlatformSpec = Map Platform PlatformVersionSpec
|
||||
type ArchitectureSpec = Map Architecture PlatformSpec
|
||||
type ToolVersionSpec = Map Version ArchitectureSpec
|
||||
@@ -63,5 +63,5 @@ type AvailableDownloads = Map Tool ToolVersionSpec
|
||||
|
||||
|
||||
data URLSource = GHCupURL
|
||||
| OwnSource URL
|
||||
| OwnSource URI
|
||||
| OwnSpec AvailableDownloads
|
||||
|
||||
@@ -14,10 +14,13 @@ import GHCup.Types
|
||||
import Data.Versions
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Network.URL
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding ( decodeUtf8
|
||||
, encodeUtf8
|
||||
)
|
||||
import Data.Aeson.Types
|
||||
import Data.Text.Encoding as E
|
||||
import URI.ByteString
|
||||
|
||||
|
||||
|
||||
@@ -32,13 +35,14 @@ deriveJSON defaultOptions ''VSep
|
||||
deriveJSON defaultOptions ''VUnit
|
||||
|
||||
|
||||
instance ToJSON URL where
|
||||
toJSON = toJSON . exportURL
|
||||
instance ToJSON URI where
|
||||
toJSON = toJSON . decodeUtf8 . serializeURIRef'
|
||||
|
||||
instance FromJSON URL where
|
||||
parseJSON = withText "URL" $ \t -> case importURL (T.unpack t) of
|
||||
Just x -> pure x
|
||||
Nothing -> fail "Could not parse URL, failure in importURL"
|
||||
instance FromJSON URI where
|
||||
parseJSON = withText "URL" $ \t ->
|
||||
case parseURI strictURIParserOptions (encodeUtf8 t) of
|
||||
Right x -> pure x
|
||||
Left e -> fail . show $ e
|
||||
|
||||
instance ToJSON Versioning where
|
||||
toJSON = toJSON . prettyV
|
||||
@@ -62,8 +66,8 @@ instance ToJSONKey (Maybe Versioning) where
|
||||
Nothing -> T.pack "unknown_version"
|
||||
|
||||
instance FromJSONKey (Maybe Versioning) where
|
||||
fromJSONKey = FromJSONKeyTextParser
|
||||
$ \t -> if t == T.pack "unknown_version" then pure Nothing else pure $ just t
|
||||
fromJSONKey = FromJSONKeyTextParser $ \t ->
|
||||
if t == T.pack "unknown_version" then pure Nothing else pure $ just t
|
||||
where
|
||||
just t = case versioning t of
|
||||
Right x -> pure x
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
module GHCup.Types.Optics where
|
||||
|
||||
import GHCup.Types
|
||||
import Optics
|
||||
import Data.ByteString ( ByteString )
|
||||
import GHCup.Types
|
||||
import Optics
|
||||
import URI.ByteString
|
||||
|
||||
makePrisms ''Tool
|
||||
makePrisms ''Architecture
|
||||
@@ -14,3 +16,26 @@ makeLenses ''PlatformResult
|
||||
makeLenses ''ToolRequest
|
||||
|
||||
|
||||
uriSchemeL' :: Lens' (URIRef Absolute) Scheme
|
||||
uriSchemeL' = lensVL uriSchemeL
|
||||
|
||||
schemeBSL' :: Lens' Scheme ByteString
|
||||
schemeBSL' = lensVL schemeBSL
|
||||
|
||||
authorityL' :: Lens' (URIRef a) (Maybe Authority)
|
||||
authorityL' = lensVL authorityL
|
||||
|
||||
authorityHostL' :: Lens' Authority Host
|
||||
authorityHostL' = lensVL authorityHostL
|
||||
|
||||
authorityPortL' :: Lens' Authority (Maybe Port)
|
||||
authorityPortL' = lensVL authorityPortL
|
||||
|
||||
portNumberL' :: Lens' Port Int
|
||||
portNumberL' = lensVL portNumberL
|
||||
|
||||
hostBSL' :: Lens' Host ByteString
|
||||
hostBSL' = lensVL hostBSL
|
||||
|
||||
pathL' :: Lens' (URIRef a) ByteString
|
||||
pathL' = lensVL pathL
|
||||
|
||||
Reference in New Issue
Block a user