Index: sdk/lib/_internal/pub_generated/lib/src/io.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub_generated/lib/src/io.dart |
similarity index 89% |
copy from sdk/lib/_internal/pub/lib/src/io.dart |
copy to sdk/lib/_internal/pub_generated/lib/src/io.dart |
index 3f7f553f945b6497ea9678265467652753d63f63..35df8d1d8232bce4a40cbbdf65e5bc38f52617ee 100644 |
--- a/sdk/lib/_internal/pub/lib/src/io.dart |
+++ b/sdk/lib/_internal/pub_generated/lib/src/io.dart |
@@ -35,7 +35,7 @@ final _descriptorPool = new Pool(32); |
/// Determines if a file or directory exists at [path]. |
bool entryExists(String path) => |
- dirExists(path) || fileExists(path) || linkExists(path); |
+ dirExists(path) || fileExists(path) || linkExists(path); |
/// Returns whether [link] exists on the file system. |
/// |
@@ -59,8 +59,8 @@ bool fileExists(String file) => new File(file).existsSync(); |
/// directories. |
String canonicalize(String pathString) { |
var seen = new Set<String>(); |
- var components = new Queue<String>.from( |
- path.split(path.normalize(path.absolute(pathString)))); |
+ var components = |
+ new Queue<String>.from(path.split(path.normalize(path.absolute(pathString)))); |
// The canonical path, built incrementally as we iterate through [components]. |
var newPath = components.removeFirst(); |
@@ -70,8 +70,8 @@ String canonicalize(String pathString) { |
// resolved in turn. |
while (!components.isEmpty) { |
seen.add(path.join(newPath, path.joinAll(components))); |
- var resolvedPath = resolveLink( |
- path.join(newPath, components.removeFirst())); |
+ var resolvedPath = |
+ resolveLink(path.join(newPath, components.removeFirst())); |
var relative = path.relative(resolvedPath, from: newPath); |
// If the resolved path of the component relative to `newPath` is just ".", |
@@ -143,8 +143,8 @@ String resolveLink(String link) { |
var seen = new Set<String>(); |
while (linkExists(link) && !seen.contains(link)) { |
seen.add(link); |
- link = path.normalize(path.join( |
- path.dirname(link), new Link(link).targetSync())); |
+ link = |
+ path.normalize(path.join(path.dirname(link), new Link(link).targetSync())); |
} |
return link; |
} |
@@ -164,8 +164,8 @@ List<int> readBinaryFile(String file) { |
/// Creates [file] and writes [contents] to it. |
/// |
/// If [dontLogContents] is true, the contents of the file will never be logged. |
-String writeTextFile(String file, String contents, |
- {bool dontLogContents: false}) { |
+String writeTextFile(String file, String contents, {bool dontLogContents: |
+ false}) { |
// Sanity check: don't spew a huge file. |
log.io("Writing ${contents.length} characters to text file $file."); |
if (!dontLogContents && contents.length < 1024 * 1024) { |
@@ -272,9 +272,8 @@ String createSystemTempDir() { |
/// |
/// The returned paths are guaranteed to begin with [dir]. Broken symlinks won't |
/// be returned. |
-List<String> listDir(String dir, {bool recursive: false, |
- bool includeHidden: false, bool includeDirs: true, |
- Iterable<String> whitelist}) { |
+List<String> listDir(String dir, {bool recursive: false, bool includeHidden: |
+ false, bool includeDirs: true, Iterable<String> whitelist}) { |
if (whitelist == null) whitelist = []; |
var whitelistFilter = createFileFilter(whitelist); |
@@ -283,8 +282,8 @@ List<String> listDir(String dir, {bool recursive: false, |
// readability than most code in pub. In particular, it avoids using the path |
// package, since re-parsing a path is very expensive relative to string |
// operations. |
- return new Directory(dir).listSync( |
- recursive: recursive, followLinks: true).where((entity) { |
+ return new Directory( |
+ dir).listSync(recursive: recursive, followLinks: true).where((entity) { |
if (!includeDirs && entity is Directory) return false; |
if (entity is Link) return false; |
if (includeHidden) return true; |
@@ -304,11 +303,11 @@ List<String> listDir(String dir, {bool recursive: false, |
// If the basename is whitelisted, don't count its "/." as making the file |
// hidden. |
- var whitelistedBasename = whitelistFilter.firstWhere(pathInDir.contains, |
- orElse: () => null); |
+ var whitelistedBasename = |
+ whitelistFilter.firstWhere(pathInDir.contains, orElse: () => null); |
if (whitelistedBasename != null) { |
- pathInDir = pathInDir.substring( |
- 0, pathInDir.length - whitelistedBasename.length); |
+ pathInDir = |
+ pathInDir.substring(0, pathInDir.length - whitelistedBasename.length); |
} |
if (pathInDir.contains("/.")) return false; |
@@ -356,8 +355,7 @@ void _attempt(String description, void operation()) { |
var reason = getErrorReason(error); |
if (reason == null) rethrow; |
- log.io("Failed to $description because $reason. " |
- "Retrying in 50ms."); |
+ log.io("Failed to $description because $reason. " "Retrying in 50ms."); |
sleep(new Duration(milliseconds: 50)); |
} |
} |
@@ -368,9 +366,10 @@ void _attempt(String description, void operation()) { |
var reason = getErrorReason(error); |
if (reason == null) rethrow; |
- fail("Failed to $description because $reason.\n" |
- "This may be caused by a virus scanner or having a file\n" |
- "in the directory open in another application."); |
+ fail( |
+ "Failed to $description because $reason.\n" |
+ "This may be caused by a virus scanner or having a file\n" |
+ "in the directory open in another application."); |
} |
} |
@@ -398,8 +397,8 @@ void tryDeleteEntry(String path) { |
try { |
deleteEntry(path); |
} catch (error, stackTrace) { |
- log.fine("Failed to delete $path: $error\n" |
- "${new Chain.forTrace(stackTrace)}"); |
+ log.fine( |
+ "Failed to delete $path: $error\n" "${new Chain.forTrace(stackTrace)}"); |
} |
} |
@@ -434,8 +433,7 @@ void renameDir(String from, String to) { |
/// symlink to the target. Otherwise, uses the [target] path unmodified. |
/// |
/// Note that on Windows, only directories may be symlinked to. |
-void createSymlink(String target, String symlink, |
- {bool relative: false}) { |
+void createSymlink(String target, String symlink, {bool relative: false}) { |
if (relative) { |
// Relative junction points are not supported on Windows. Instead, just |
// make sure we have a clean absolute path because it will interpret a |
@@ -483,7 +481,12 @@ final bool runningFromSdk = Platform.script.path.endsWith('.snapshot'); |
String assetPath(String target) { |
if (runningFromSdk) { |
return path.join( |
- sdk.rootDirectory, 'lib', '_internal', 'pub', 'asset', target); |
+ sdk.rootDirectory, |
+ 'lib', |
+ '_internal', |
+ 'pub', |
+ 'asset', |
+ target); |
} else { |
return path.join(pubRoot, 'asset', target); |
} |
@@ -520,8 +523,8 @@ String get repoRoot { |
} |
/// A line-by-line stream of standard input. |
-final Stream<String> stdinLines = streamToLines( |
- new ByteStream(stdin).toStringStream()); |
+final Stream<String> stdinLines = |
+ streamToLines(new ByteStream(stdin).toStringStream()); |
/// Displays a message and reads a yes/no confirmation from the user. |
/// |
@@ -537,8 +540,8 @@ Future<bool> confirm(String message) { |
} else { |
stdout.write(log.format("$message (y/n)? ")); |
} |
- return streamFirst(stdinLines) |
- .then((line) => new RegExp(r"^[yY]").hasMatch(line)); |
+ return streamFirst( |
+ stdinLines).then((line) => new RegExp(r"^[yY]").hasMatch(line)); |
} |
/// Reads and discards all output from [stream]. |
@@ -555,10 +558,8 @@ Future drainStream(Stream stream) { |
/// exited already. This is useful to prevent Future chains from proceeding |
/// after you've decided to exit. |
Future flushThenExit(int status) { |
- return Future.wait([ |
- stdout.close(), |
- stderr.close() |
- ]).then((_) => exit(status)); |
+ return Future.wait( |
+ [stdout.close(), stderr.close()]).then((_) => exit(status)); |
} |
/// Returns a [EventSink] that pipes all data to [consumer] and a [Future] that |
@@ -581,8 +582,8 @@ Pair<EventSink, Future> consumerToSink(StreamConsumer consumer) { |
/// more data or errors will be piped from [stream] to [sink]. If |
/// [cancelOnError] and [closeSink] are both true, [sink] will then be |
/// closed. |
-Future store(Stream stream, EventSink sink, |
- {bool cancelOnError: true, bool closeSink: true}) { |
+Future store(Stream stream, EventSink sink, {bool cancelOnError: true, |
+ bool closeSink: true}) { |
var completer = new Completer(); |
stream.listen(sink.add, onError: (e, stackTrace) { |
sink.addError(e, stackTrace); |
@@ -608,10 +609,14 @@ Future store(Stream stream, EventSink sink, |
Future<PubProcessResult> runProcess(String executable, List<String> args, |
{workingDir, Map<String, String> environment}) { |
return _descriptorPool.withResource(() { |
- return _doProcess(Process.run, executable, args, workingDir, environment) |
- .then((result) { |
- var pubResult = new PubProcessResult( |
- result.stdout, result.stderr, result.exitCode); |
+ return _doProcess( |
+ Process.run, |
+ executable, |
+ args, |
+ workingDir, |
+ environment).then((result) { |
+ var pubResult = |
+ new PubProcessResult(result.stdout, result.stderr, result.exitCode); |
log.processResult(executable, pubResult); |
return pubResult; |
}); |
@@ -629,8 +634,12 @@ Future<PubProcessResult> runProcess(String executable, List<String> args, |
Future<PubProcess> startProcess(String executable, List<String> args, |
{workingDir, Map<String, String> environment}) { |
return _descriptorPool.request().then((resource) { |
- return _doProcess(Process.start, executable, args, workingDir, environment) |
- .then((ioProcess) { |
+ return _doProcess( |
+ Process.start, |
+ executable, |
+ args, |
+ workingDir, |
+ environment).then((ioProcess) { |
var process = new PubProcess(ioProcess); |
process.exitCode.whenComplete(resource.release); |
return process; |
@@ -640,11 +649,11 @@ Future<PubProcess> startProcess(String executable, List<String> args, |
/// Like [runProcess], but synchronous. |
PubProcessResult runProcessSync(String executable, List<String> args, |
- {String workingDir, Map<String, String> environment}) { |
- var result = _doProcess( |
- Process.runSync, executable, args, workingDir, environment); |
- var pubResult = new PubProcessResult( |
- result.stdout, result.stderr, result.exitCode); |
+ {String workingDir, Map<String, String> environment}) { |
+ var result = |
+ _doProcess(Process.runSync, executable, args, workingDir, environment); |
+ var pubResult = |
+ new PubProcessResult(result.stdout, result.stderr, result.exitCode); |
log.processResult(executable, pubResult); |
return pubResult; |
} |
@@ -711,17 +720,15 @@ class PubProcess { |
/// Creates a new [PubProcess] wrapping [process]. |
PubProcess(Process process) |
- : _process = process { |
+ : _process = process { |
var errorGroup = new ErrorGroup(); |
var pair = consumerToSink(process.stdin); |
_stdin = pair.first; |
_stdinClosed = errorGroup.registerFuture(pair.last); |
- _stdout = new ByteStream( |
- errorGroup.registerStream(process.stdout)); |
- _stderr = new ByteStream( |
- errorGroup.registerStream(process.stderr)); |
+ _stdout = new ByteStream(errorGroup.registerStream(process.stdout)); |
+ _stderr = new ByteStream(errorGroup.registerStream(process.stderr)); |
var exitCodeCompleter = new Completer(); |
_exitCode = errorGroup.registerFuture(exitCodeCompleter.future); |
@@ -730,15 +737,15 @@ class PubProcess { |
/// Sends [signal] to the underlying process. |
bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]) => |
- _process.kill(signal); |
+ _process.kill(signal); |
} |
/// Calls [fn] with appropriately modified arguments. |
/// |
/// [fn] should have the same signature as [Process.start], except that the |
/// returned value may have any return type. |
-_doProcess(Function fn, String executable, List<String> args, |
- String workingDir, Map<String, String> environment) { |
+_doProcess(Function fn, String executable, List<String> args, String workingDir, |
+ Map<String, String> environment) { |
// TODO(rnystrom): Should dart:io just handle this? |
// Spawning a process on Windows will not look for the executable in the |
// system path. So, if executable looks like it needs that (i.e. it doesn't |
@@ -751,7 +758,9 @@ _doProcess(Function fn, String executable, List<String> args, |
log.process(executable, args, workingDir == null ? '.' : workingDir); |
- return fn(executable, args, |
+ return fn( |
+ executable, |
+ args, |
workingDirectory: workingDir, |
environment: environment); |
} |
@@ -775,8 +784,8 @@ Future timeout(Future input, int milliseconds, Uri url, String description) { |
var timer = new Timer(duration, () { |
// Include the duration ourselves in the message instead of passing it to |
// TimeoutException since we show nicer output. |
- var message = 'Timed out after ${niceDuration(duration)} while ' |
- '$description.'; |
+ var message = |
+ 'Timed out after ${niceDuration(duration)} while ' '$description.'; |
if (url.host == "pub.dartlang.org" || |
url.host == "storage.googleapis.com") { |
@@ -808,8 +817,8 @@ Future timeout(Future input, int milliseconds, Uri url, String description) { |
Future withTempDir(Future fn(String path)) { |
return new Future.sync(() { |
var tempDir = createSystemTempDir(); |
- return new Future.sync(() => fn(tempDir)) |
- .whenComplete(() => deleteEntry(tempDir)); |
+ return new Future.sync( |
+ () => fn(tempDir)).whenComplete(() => deleteEntry(tempDir)); |
}); |
} |
@@ -847,15 +856,12 @@ Future<bool> extractTarGz(Stream<List<int>> stream, String destination) { |
// std{out,err}Sink. |
store(process.stdout.handleError((_) {}), stdout, closeSink: false); |
store(process.stderr.handleError((_) {}), stderr, closeSink: false); |
- return Future.wait([ |
- store(stream, process.stdin), |
- process.exitCode |
- ]); |
+ return Future.wait([store(stream, process.stdin), process.exitCode]); |
}).then((results) { |
var exitCode = results[1]; |
if (exitCode != exit_codes.SUCCESS) { |
- throw new Exception("Failed to extract .tar.gz stream to $destination " |
- "(exit code $exitCode)."); |
+ throw new Exception( |
+ "Failed to extract .tar.gz stream to $destination " "(exit code $exitCode)."); |
} |
log.fine("Extracted .tar.gz stream to $destination. Exit code $exitCode."); |
}); |
@@ -874,8 +880,8 @@ bool _computeNoUnknownKeyword() { |
"Failed to run tar (exit code ${result.exitCode}):\n${result.stderr}"); |
} |
- var match = new RegExp(r"^tar \(GNU tar\) (\d+).(\d+)\n") |
- .firstMatch(result.stdout); |
+ var match = |
+ new RegExp(r"^tar \(GNU tar\) (\d+).(\d+)\n").firstMatch(result.stdout); |
if (match == null) return false; |
var major = int.parse(match[1]); |
@@ -888,8 +894,8 @@ String get pathTo7zip { |
return path.join(repoRoot, 'third_party', '7zip', '7za.exe'); |
} |
-Future<bool> _extractTarGzWindows(Stream<List<int>> stream, |
- String destination) { |
+Future<bool> _extractTarGzWindows(Stream<List<int>> stream, String destination) |
+ { |
// TODO(rnystrom): In the repo's history, there is an older implementation of |
// this that does everything in memory by piping streams directly together |
// instead of writing out temp files. The code is simpler, but unfortunately, |
@@ -908,16 +914,14 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream, |
return runProcess(pathTo7zip, ['e', 'data.tar.gz'], workingDir: tempDir); |
}).then((result) { |
if (result.exitCode != exit_codes.SUCCESS) { |
- throw new Exception('Could not un-gzip (exit code ${result.exitCode}). ' |
- 'Error:\n' |
- '${result.stdout.join("\n")}\n' |
- '${result.stderr.join("\n")}'); |
+ throw new Exception( |
+ 'Could not un-gzip (exit code ${result.exitCode}). ' 'Error:\n' |
+ '${result.stdout.join("\n")}\n' '${result.stderr.join("\n")}'); |
} |
// Find the tar file we just created since we don't know its name. |
- var tarFile = listDir(tempDir).firstWhere( |
- (file) => path.extension(file) == '.tar', |
- orElse: () { |
+ var tarFile = listDir( |
+ tempDir).firstWhere((file) => path.extension(file) == '.tar', orElse: () { |
throw new FormatException('The gzip file did not contain a tar file.'); |
}); |
@@ -925,10 +929,9 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream, |
return runProcess(pathTo7zip, ['x', tarFile], workingDir: destination); |
}).then((result) { |
if (result.exitCode != exit_codes.SUCCESS) { |
- throw new Exception('Could not un-tar (exit code ${result.exitCode}). ' |
- 'Error:\n' |
- '${result.stdout.join("\n")}\n' |
- '${result.stderr.join("\n")}'); |
+ throw new Exception( |
+ 'Could not un-tar (exit code ${result.exitCode}). ' 'Error:\n' |
+ '${result.stdout.join("\n")}\n' '${result.stderr.join("\n")}'); |
} |
return true; |
}); |