Skip to content
Permalink
Browse files

Merge pull request #1357 from input-output-hk/broken-regex

fix regex that failed for multiline mkFunctions and add a test
  • Loading branch information...
shmish111 committed Aug 13, 2019
2 parents 68a5529 + 61a08e1 commit 53ba606ee99854f29226db591d90eaaf0b7b8288
@@ -44,7 +44,11 @@ replaceModuleName script =
ensureMkFunctionExists :: Text -> Text
ensureMkFunctionExists script =
let scriptString = Text.unpack script
regex = Regex.mkRegex "^\\$\\(mkFunctions \\[.*])"
-- I don't really like this regex as it doesn't require properly formed mkFunctions
-- however I couldn't find a better regex that worked for all current usecases
-- additionally I think this check is strong enough to decide whether to add the
-- empty $(mkFunctions [])
regex = Regex.mkRegex "^\\$\\(mkFunctions[ \n\t].*"
mMatches = Regex.matchRegexAll regex scriptString
in case mMatches of
Nothing -> script <> "\n$(mkFunctions [])"
@@ -103,7 +103,11 @@ startGame =
-- Player 2's wallet is aware of the game address.
startWatching gameAddress

$(mkFunctions ['lock, 'guess, 'startGame])
$(mkFunctions
['lock
, 'guess
, 'startGame
])

{- Note [Contract endpoints]

0 comments on commit 53ba606

Please sign in to comment.
You can’t perform that action at this time.