Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: lib/src/executable.dart

Issue 1226083002: Fix several Windows issues. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/executable.dart
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index 863f306f672e01c03349298ddf37efffcd3faa6c..788a8329f4d0b4a1cfcca05b76904bb4254dc476 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -12,6 +12,7 @@ import 'package:path/path.dart' as p;
import 'package:stack_trace/stack_trace.dart';
import 'barback/asset_environment.dart';
+import 'cr_lf_remover.dart';
import 'entrypoint.dart';
import 'exit_codes.dart' as exit_codes;
import 'io.dart';
@@ -127,8 +128,8 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
// Note: we're not using process.std___.pipe(std___) here because
// that prevents pub from also writing to the output streams.
- process.stderr.listen(stderr.add);
- process.stdout.listen(stdout.add);
+ _forwardOutput(process.stderr, stderr);
+ _forwardOutput(process.stdout, stdout);
stdin.listen(process.stdin.add);
return process.exitCode;
@@ -231,8 +232,8 @@ Future<int> runSnapshot(String path, Iterable<String> args, {recompile(),
// Note: we're not using process.std___.pipe(std___) here because
// that prevents pub from also writing to the output streams.
- process.stderr.listen(stderr.add);
- process.stdout.listen(stdout.add);
+ _forwardOutput(process.stderr, stderr);
+ _forwardOutput(process.stdout, stdout);
input.listen(process.stdin.add);
return process.exitCode;
@@ -261,6 +262,19 @@ void _forwardSignals(Process process) {
}
}
+/// Forwards output from a Process's output stream to the corresponding stream
+/// for pub.
+///
+/// On Windows, this replaces any CR LF sequences in the process's output with
+/// just LF to work around sdk#19334.
+void _forwardOutput(Stream<List<int>> stream, Sink<List<int>> sink) {
+ if (Platform.isWindows) {
+ log.fine("filtering out CR LF");
+ stream = const CRLFRemover().bind(stream);
+ }
+ stream.listen(sink.add);
+}
+
/// Runs the executable snapshot at [snapshotPath].
Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath,
List<String> args) {
« lib/src/cr_lf_remover.dart ('K') | « lib/src/cr_lf_remover.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698