From bb4813de9bcd49a37f8e8871311e7201c6c7e29a Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 26 Jan 2019 23:46:55 +0100 Subject: Reaktor.Plugins.System: compile hPattern once --- src/Reaktor/Plugins/System/Internal.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Reaktor/Plugins/System/Internal.hs') diff --git a/src/Reaktor/Plugins/System/Internal.hs b/src/Reaktor/Plugins/System/Internal.hs index 45b7329..aa60452 100644 --- a/src/Reaktor/Plugins/System/Internal.hs +++ b/src/Reaktor/Plugins/System/Internal.hs @@ -5,7 +5,8 @@ module Reaktor.Plugins.System.Internal where import Prelude.Extended import Data.Aeson import Reaktor () - +import Text.Regex.PCRE.Light (Regex) +import qualified Text.Regex.PCRE.Light as RE -- TODO this needs better names :) @@ -46,7 +47,7 @@ instance FromJSON Config where data Hook = Hook { hActivate :: Activate - , hPattern :: Maybe ByteString + , hPattern :: Maybe Regex , hCommand :: CaptureOr Command , hArguments :: [CaptureOr Text] , hWorkDir :: Maybe FilePath @@ -60,7 +61,7 @@ instance FromJSON Hook where Object v -> Hook <$> v .:? "activate" .!= Query - <*> v .:? "pattern" + <*> (fmap (flip RE.compile [RE.utf8]) <$> v .:? "pattern") <*> v .: "command" <*> v .:? "arguments" .!= [] <*> v .:? "workdir" -- cgit v1.2.3