| Index: utils/pub/utils.dart
|
| diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
|
| index 7a257d4e16df187fbdfd7b97bc3a18269a109c99..38fa49027fea01d6622cdf17863a4fa91f0545ad 100644
|
| --- a/utils/pub/utils.dart
|
| +++ b/utils/pub/utils.dart
|
| @@ -226,8 +226,8 @@ final RegExp _lineRegexp = new RegExp(r"\r\n|\r|\n");
|
| /// newline is ignored.
|
| Stream<String> streamToLines(Stream<String> stream) {
|
| var buffer = new StringBuffer();
|
| - return stream.transform(new StreamTransformer.from(
|
| - onData: (chunk, sink) {
|
| + return wrapStream(stream.transform(new StreamTransformer(
|
| + handleData: (chunk, sink) {
|
| var lines = chunk.split(_lineRegexp);
|
| var leftover = lines.removeLast();
|
| for (var line in lines) {
|
| @@ -240,10 +240,24 @@ Stream<String> streamToLines(Stream<String> stream) {
|
| sink.add(line);
|
| }
|
| buffer.add(leftover);
|
| - }, onDone: (sink) {
|
| + },
|
| + handleDone: (sink) {
|
| if (!buffer.isEmpty) sink.add(buffer.toString());
|
| sink.close();
|
| - }));
|
| + })));
|
| +}
|
| +
|
| +// TODO(nweiz): remove this when issue 8310 is fixed.
|
| +/// Returns a [Stream] identical to [stream], but piped through a new
|
| +/// [StreamController]. This exists to work around issue 8310.
|
| +Stream wrapStream(Stream stream) {
|
| + var controller = stream.isBroadcast
|
| + ? new StreamController.broadcast()
|
| + : new StreamController();
|
| + stream.listen(controller.add,
|
| + onError: (e) => controller.signalError(e),
|
| + onDone: controller.close);
|
| + return controller.stream;
|
| }
|
|
|
| /// Like [Iterable.where], but allows [test] to return [Future]s and uses the
|
|
|