Skip to content

Commit

Permalink
Fix symlink test
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Dec 19, 2022
1 parent 46decef commit b93d534
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion build_runner_core/lib/src/asset/writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ class DelayedAssetWriter implements RunnerAssetWriter {
/// Obtain a [RunnerAssetReader] capable of reading pending writes of this
/// writer (before they are persisted with [onBuildComplete]).
RunnerAssetReader reader(RunnerAssetReader delegate, String rootPackage) {
return _DelayAwareReader(delegate, this, rootPackage);
final reader = _DelayAwareReader(delegate, this, rootPackage);

if (delegate is PathProvidingAssetReader) {
// `createMergedOutputDirectories` needs a path providing asset reader, so
// keep that interface intact if we're wrapping a reader capable of doing
// that.
return _PathProvidingDelayAwareReader(
reader, delegate as PathProvidingAssetReader);
} else {
return reader;
}
}

@override
Expand Down Expand Up @@ -136,3 +146,37 @@ class _DelayAwareReader extends AssetReader implements RunnerAssetReader {
return encoding.decode(await readAsBytes(id));
}
}

class _PathProvidingDelayAwareReader extends AssetReader
with RunnerAssetReader
implements PathProvidingAssetReader {
final _DelayAwareReader _reader;
final PathProvidingAssetReader _original;

_PathProvidingDelayAwareReader(this._reader, this._original);

@override
Future<bool> canRead(AssetId id) {
return _reader.canRead(id);
}

@override
Stream<AssetId> findAssets(Glob glob, {String? package}) {
return _reader.findAssets(glob, package: package);
}

@override
String pathTo(AssetId id) {
return _original.pathTo(id);
}

@override
Future<List<int>> readAsBytes(AssetId id) {
return _reader.readAsBytes(id);
}

@override
Future<String> readAsString(AssetId id, {Encoding encoding = utf8}) {
return _reader.readAsString(id, encoding: encoding);
}
}

0 comments on commit b93d534

Please sign in to comment.