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

Unified Diff: lib/dartdoc/dartdoc.dart

Issue 10392023: Change dart:io to use Future for one-shot operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding stable test binaries Created 8 years, 7 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
« no previous file with comments | « lib/compiler/implementation/lib/io.dart ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dartdoc/dartdoc.dart
diff --git a/lib/dartdoc/dartdoc.dart b/lib/dartdoc/dartdoc.dart
index 738026ea786af11ef65946c4c1a1e7a3f70fea7a..d336b5dc9c63dfbccaa650027bdd37f46606031f 100644
--- a/lib/dartdoc/dartdoc.dart
+++ b/lib/dartdoc/dartdoc.dart
@@ -165,20 +165,21 @@ void cleanOutputDirectory(String path) {
Future copyFiles(String from, String to) {
final completer = new Completer();
final fromDir = new Directory(from);
- fromDir.onFile = (path) {
+ final lister = fromDir.list(recursive: false);
+
+ lister.onFile = (path) {
final name = basename(path);
// TODO(rnystrom): Hackish. Ignore 'hidden' files like .DS_Store.
if (name.startsWith('.')) return;
- new File(path).readAsBytes((bytes) {
+ new File(path).readAsBytes().then((bytes) {
final outFile = new File('$to/$name');
final stream = outFile.openOutputStream(FileMode.WRITE);
stream.write(bytes, copyBuffer: false);
stream.close();
});
};
- fromDir.onDone = (done) => completer.complete(true);
- fromDir.list(recursive: false);
+ lister.onDone = (done) => completer.complete(true);
return completer.future;
}
@@ -189,12 +190,12 @@ Future copyFiles(String from, String to) {
Future compileScript(String compilerPath, String libDir,
String dartPath, String jsPath) {
final completer = new Completer();
- onExit(int exitCode, String stdout, String stderr) {
- if (exitCode != 0) {
+ onExit(ProcessResult result) {
+ if (result.exitCode != 0) {
final message = 'Non-zero exit code from $compilerPath';
print('$message.');
- print(stdout);
- print(stderr);
+ print(result.stdout);
+ print(result.stderr);
throw message;
}
completer.complete(true);
@@ -207,10 +208,14 @@ Future compileScript(String compilerPath, String libDir,
}
print('Compiling $dartPath to $jsPath');
- new Process.run(compilerPath, [
+ var processFuture = Process.run(compilerPath, [
'--libdir=$libDir', '--out=$jsPath',
'--compile-only', '--enable-type-checks', '--warnings-as-errors',
- dartPath], null, onExit).onError = onError;
+ dartPath]);
+
+ processFuture.handleException(onError);
+ processFuture.then(onExit);
+
return completer.future;
}
« no previous file with comments | « lib/compiler/implementation/lib/io.dart ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698