Unverified Commit 4a966088 authored by Andrew Kolos's avatar Andrew Kolos Committed by GitHub

Reland "Stop recursively including assets from asset directories" (#120312)

* stop recursively including assets from asset directories

* remove unused imports

* lint
parent 2303f422
......@@ -909,22 +909,6 @@ class ManifestAssetBundle implements AssetBundle {
attributedPackage: attributedPackage,
);
}
final Iterable<Directory> nonVariantSubDirectories = entities
.whereType<Directory>()
.where((Directory directory) => !_assetVariantDirectoryRegExp.hasMatch(directory.basename));
for (final Directory dir in nonVariantSubDirectories) {
final String relativePath = _fileSystem.path.relative(dir.path, from: assetBase);
final Uri relativePathsUri = Uri.directory(relativePath, windows: _platform.isWindows);
_parseAssetsFromFolder(packageConfig,
flutterManifest,
assetBase,
cache,
result,
relativePathsUri
);
}
}
void _parseAssetFromFile(
......
......@@ -69,6 +69,51 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('wildcard directories do not include subdirectories', () async {
globals.fs.file('.packages').createSync();
globals.fs.file('pubspec.yaml').writeAsStringSync(
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
assets:
- assets/foo/
- assets/bar/lizard.png
'''
);
final List<String> assets = <String>[
'assets/foo/dog.png',
'assets/foo/sub/cat.png',
'assets/bar/lizard.png',
'assets/bar/sheep.png'
];
for (final String asset in assets) {
final File assetFile = globals.fs.file(
globals.fs.path.joinAll(asset.split('/'))
);
assetFile.createSync(recursive: true);
}
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(packagesPath: '.packages');
expect(bundle.entries.keys, unorderedEquals(<String>[
'AssetManifest.json',
'AssetManifest.bin',
'FontManifest.json',
'NOTICES.Z',
'assets/foo/dog.png',
'assets/bar/lizard.png'
]));
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('wildcard directories are updated when filesystem changes', () async {
final File packageFile = globals.fs.file('.packages')..createSync();
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
......
......@@ -54,6 +54,9 @@ dependencies:
flutter:
assets:
- assets/
- assets/notAVariant/
- assets/folder/
- assets/normalFolder/
'''
);
});
......@@ -184,6 +187,7 @@ dependencies:
flutter:
assets:
- assets/
- assets/somewhereElse/
'''
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment