Index: utils/pub/io.dart |
diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
index 968f3546fbc4bcf77b02797f0ab46dc99357435c..1a5a7b330fe679ccf9c63534a1d15ce7519bb52d 100644 |
--- a/utils/pub/io.dart |
+++ b/utils/pub/io.dart |
@@ -605,6 +605,19 @@ Future<String> consumeStringInputStream(StringInputStream stream) { |
return completer.future; |
} |
+/// Wrap an InputStream in a ListInputStream. This eagerly drains the [source] |
+/// input stream. This is useful for spawned processes which will not exit until |
+/// their output streams have been drained. |
+/// TODO(rnystrom): Get rid of this once #7218 is fixed. |
+InputStream wrapInputStream(InputStream source) { |
+ var sink = new ListInputStream(); |
+ // TODO(nweiz): Due to issuee 3657, pipeInputToInput naturally avoids calling |
+ // both onClosed and onError. If 3657 gets fixed before 7013, we'll need to do |
+ // that explicitly. |
+ pipeInputToInput(source, sink); |
+ return sink; |
+} |
+ |
/// Spawns and runs the process located at [executable], passing in [args]. |
/// Returns a [Future] that will complete with the results of the process after |
/// it has ended. |