Skip to content

Commit 9209a76

Browse files
committed
fixed an issue running dartdoc as a pub global activated snapshot
1 parent 46af07b commit 9209a76

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.5.0+1
2+
* [bug] fixed an issue running dartdoc as a pub global activated snapshot
3+
14
## 0.5.0
25
* [health] remove calls to deprecated methods
36
* [health] remove workaround when sorting empty iterable

lib/resource_loader.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ Future<String> loadAsString(String path) {
2626
if (!path.startsWith('package:')) {
2727
throw new ArgumentError('path must begin with package:');
2828
}
29-
return new Resource(path).readAsString().catchError((_) async {
30-
// TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
31-
var bytes = await _doLoad(path);
32-
return new String.fromCharCodes(bytes);
33-
});
29+
30+
try {
31+
return new Resource(path).readAsString().catchError((_) {
32+
// TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
33+
return _doLoad(path).then((bytes) => new String.fromCharCodes(bytes));
34+
});
35+
} catch (_) {
36+
return _doLoad(path).then((bytes) => new String.fromCharCodes(bytes));
37+
}
3438
}
3539

3640
/// Loads a `package:` resource as an [List<int>].
@@ -39,10 +43,12 @@ Future<List<int>> loadAsBytes(String path) {
3943
throw new ArgumentError('path must begin with package:');
4044
}
4145

42-
return new Resource(path).readAsBytes().catchError((_) {
46+
try {
4347
// TODO: Remove once https://github.com/dart-lang/pub/issues/22 is fixed.
48+
return new Resource(path).readAsBytes().catchError((_) => _doLoad(path));
49+
} catch (_) {
4450
return _doLoad(path);
45-
});
51+
}
4652
}
4753

4854
/// Determine how to do the load. HTTP? Snapshotted? From source?

0 commit comments

Comments
 (0)