From a28f1536c8b29d22adb7d7e0a5d60665496fb769 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Tue, 31 Jan 2017 03:54:53 -0800 Subject: [PATCH] packager: json reporter Summary: The idea is to make it easier to interact with tools consuming the packager's output. For example, Nuclide. Do you think that'd work well? Reviewed By: davidaurelio Differential Revision: D4482041 fbshipit-source-id: 6c64d7963195a4d786ed8902640f9e9f279f5f83 --- .../react-packager/src/lib/JsonReporter.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 packager/react-packager/src/lib/JsonReporter.js diff --git a/packager/react-packager/src/lib/JsonReporter.js b/packager/react-packager/src/lib/JsonReporter.js new file mode 100644 index 000000000..6d47bc0c5 --- /dev/null +++ b/packager/react-packager/src/lib/JsonReporter.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ + +'use strict'; + +import {Writable} from 'stream'; + +class JsonReporter { + + _stream: Writable; + + constructor(stream: Writable) { + this._stream = stream; + } + + update(event: TEvent) { + this._stream.write(JSON.stringify(event) + '\n'); + } + +} + +module.exports = JsonReporter;