aboutsummaryrefslogtreecommitdiff
path: root/Messages/Internal.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-02-19 14:59:30 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-02-19 15:07:00 -0400
commit7f49e1b922d83fa6548c4c9357591b661cbf1c46 (patch)
treec20c1bbd4c88d8cf7c404e4fd7fd4cd2fa8883ae /Messages/Internal.hs
parentec1e50642b62fa3dcf5a2c9f7fd582e403c17627 (diff)
always include error-messages field when --json-error-messages
Always include error-messages field, even if empty, to make the json be self-documenting. This was a design requirement for --json-error-messages. This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Messages/Internal.hs')
-rw-r--r--Messages/Internal.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/Messages/Internal.hs b/Messages/Internal.hs
index 3972503dc..3731af16d 100644
--- a/Messages/Internal.hs
+++ b/Messages/Internal.hs
@@ -11,7 +11,8 @@ import Common
import Annex
import Types.Messages
import Messages.Concurrent
-import Messages.JSON
+import qualified Messages.JSON as JSON
+import Messages.JSON (JSONBuilder)
withMessageState :: (MessageState -> Annex a) -> Annex a
withMessageState a = Annex.getState Annex.output >>= a
@@ -30,11 +31,11 @@ outputMessage' jsonoutputter jsonbuilder msg = withMessageState $ \s -> case out
-- Buffer changes to JSON until end is reached and then emit it.
bufferJSON :: JSONBuilder -> MessageState -> Annex Bool
bufferJSON jsonbuilder s = case outputType s of
- JSONOutput _
+ JSONOutput jsonoptions
| endjson -> do
Annex.changeState $ \st ->
st { Annex.output = s { jsonBuffer = Nothing } }
- maybe noop (liftIO . flushed . emit) json
+ maybe noop (liftIO . flushed . JSON.emit . JSON.finalize jsonoptions) json
return True
| otherwise -> do
Annex.changeState $ \st ->
@@ -53,7 +54,7 @@ bufferJSON jsonbuilder s = case outputType s of
outputJSON :: JSONBuilder -> MessageState -> Annex Bool
outputJSON jsonbuilder s = case outputType s of
JSONOutput _ -> do
- maybe noop (liftIO . flushed . emit)
+ maybe noop (liftIO . flushed . JSON.emit)
(fst <$> jsonbuilder Nothing)
return True
_ -> return False