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

Side by Side Diff: utils/pub/io.dart

Issue 11174003: Use correct newline-token on windows, in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use a more generic approach. Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Helper functionality to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 library io; 8 library io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
11 import 'dart:isolate'; 11 import 'dart:isolate';
12 import 'dart:uri'; 12 import 'dart:uri';
13 13
14 import 'utils.dart'; 14 import 'utils.dart';
15 15
16 bool _isGitInstalledCache; 16 bool _isGitInstalledCache;
17 17
18 /// The cached Git command. 18 /// The cached Git command.
19 String _gitCommandCache; 19 String _gitCommandCache;
20 20
21 /** Gets the current working directory. */ 21 /** Gets the current working directory. */
22 String get workingDir => new File('.').fullPathSync(); 22 String get workingDir => new File('.').fullPathSync();
23 23
24 const Pattern NEWLINE_PATTERN = const RegExp("\r\n?|\n\r?");
25
24 /** 26 /**
25 * Prints the given string to `stderr` on its own line. 27 * Prints the given string to `stderr` on its own line.
26 */ 28 */
27 void printError(value) { 29 void printError(value) {
28 stderr.writeString(value.toString()); 30 stderr.writeString(value.toString());
29 stderr.writeString('\n'); 31 stderr.writeString('\n');
30 } 32 }
31 33
32 /** 34 /**
33 * Joins a number of path string parts into a single path. Handles 35 * Joins a number of path string parts into a single path. Handles
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 final options = new ProcessOptions(); 498 final options = new ProcessOptions();
497 if (workingDir != null) { 499 if (workingDir != null) {
498 options.workingDirectory = _getDirectory(workingDir).path; 500 options.workingDirectory = _getDirectory(workingDir).path;
499 } 501 }
500 options.environment = environment; 502 options.environment = environment;
501 503
502 var future = Process.run(executable, args, options); 504 var future = Process.run(executable, args, options);
503 return future.transform((result) { 505 return future.transform((result) {
504 // TODO(rnystrom): Remove this and change to returning one string. 506 // TODO(rnystrom): Remove this and change to returning one string.
505 List<String> toLines(String output) { 507 List<String> toLines(String output) {
506 var lines = output.split("\n"); 508 var lines = output.split(NEWLINE_PATTERN);
507 if (!lines.isEmpty() && lines.last() == "") lines.removeLast(); 509 if (!lines.isEmpty() && lines.last() == "") lines.removeLast();
508 return lines; 510 return lines;
509 } 511 }
510 return new PubProcessResult(toLines(result.stdout), 512 return new PubProcessResult(toLines(result.stdout),
511 toLines(result.stderr), 513 toLines(result.stderr),
512 result.exitCode); 514 result.exitCode);
513 }); 515 });
514 } 516 }
515 517
516 /** 518 /**
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return new Directory(entry); 755 return new Directory(entry);
754 } 756 }
755 757
756 /** 758 /**
757 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 759 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
758 */ 760 */
759 Uri _getUri(uri) { 761 Uri _getUri(uri) {
760 if (uri is Uri) return uri; 762 if (uri is Uri) return uri;
761 return new Uri.fromString(uri); 763 return new Uri.fromString(uri);
762 } 764 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698