Merge pull request #817 from dart-lang/ddc_snapshot
fixed an issue running dartdoc as a pub global activated snapshot
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7731f0..e32e77d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+## 0.5.0+1
+* [bug] fixed an issue running dartdoc as a pub global activated snapshot
+
## 0.5.0
* [health] remove calls to deprecated methods
* [health] remove workaround when sorting empty iterable
diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart
index cb21301..d4e2995 100644
--- a/lib/dartdoc.dart
+++ b/lib/dartdoc.dart
@@ -36,7 +36,7 @@
const String name = 'dartdoc';
// Update when pubspec version changes.
-const String version = '0.5.0';
+const String version = '0.5.0+1';
final String defaultOutDir = 'doc${Platform.pathSeparator}api';
diff --git a/lib/resource_loader.dart b/lib/resource_loader.dart
index 345c03a..3817576 100644
--- a/lib/resource_loader.dart
+++ b/lib/resource_loader.dart
@@ -26,11 +26,15 @@
if (!path.startsWith('package:')) {
throw new ArgumentError('path must begin with package:');
}
- return new Resource(path).readAsString().catchError((_) async {
- // TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
- var bytes = await _doLoad(path);
- return new String.fromCharCodes(bytes);
- });
+
+ try {
+ return new Resource(path).readAsString().catchError((_) {
+ // TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
+ return _doLoad(path).then((bytes) => new String.fromCharCodes(bytes));
+ });
+ } catch (_) {
+ return _doLoad(path).then((bytes) => new String.fromCharCodes(bytes));
+ }
}
/// Loads a `package:` resource as an [List<int>].
@@ -39,10 +43,12 @@
throw new ArgumentError('path must begin with package:');
}
- return new Resource(path).readAsBytes().catchError((_) {
+ try {
// TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
+ return new Resource(path).readAsBytes().catchError((_) => _doLoad(path));
+ } catch (_) {
return _doLoad(path);
- });
+ }
}
/// Determine how to do the load. HTTP? Snapshotted? From source?
diff --git a/pubspec.yaml b/pubspec.yaml
index 4fbcb08..929756d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: dartdoc
# Also update the `version` field in lib/dartdoc.dart.
-version: 0.5.0
+version: 0.5.0+1
author: Dart Team <misc@dartlang.org>
description: A documentation generator for Dart.
homepage: https://github.com/dart-lang/dartdoc