mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
[flutter_tools] Sort plugins alphabetically when refreshed (#73803)
This commit is contained in:
parent
1cb0a24a46
commit
546b521f33
|
@ -1139,7 +1139,8 @@ Future<void> refreshPluginsList(
|
|||
bool macOSPlatform = false,
|
||||
}) async {
|
||||
final List<Plugin> plugins = await findPlugins(project);
|
||||
|
||||
// Sort the plugins by name to keep ordering stable in generated files.
|
||||
plugins.sort((Plugin left, Plugin right) => left.name.compareTo(right.name));
|
||||
// TODO(franciscojma): Remove once migration is complete.
|
||||
// Write the legacy plugin files to avoid breaking existing apps.
|
||||
final bool legacyChanged = _writeFlutterPluginsListLegacy(project, plugins);
|
||||
|
|
|
@ -390,14 +390,25 @@ dependencies:
|
|||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Refreshing the plugin list creates a plugin directory when there are plugins', () async {
|
||||
createFakePlugin(fs);
|
||||
testUsingContext('Refreshing the plugin list creates a sorted plugin directory when there are plugins', () async {
|
||||
createFakePlugins(fs, <String>[
|
||||
'plugin_d',
|
||||
'plugin_a',
|
||||
'/local_plugins/plugin_c',
|
||||
'/local_plugins/plugin_b'
|
||||
]);
|
||||
|
||||
when(iosProject.existsSync()).thenReturn(true);
|
||||
|
||||
await refreshPluginsList(flutterProject);
|
||||
|
||||
expect(flutterProject.flutterPluginsFile.existsSync(), true);
|
||||
expect(flutterProject.flutterPluginsDependenciesFile.existsSync(), true);
|
||||
|
||||
final String pluginsFileContents = flutterProject.flutterPluginsFile.readAsStringSync();
|
||||
expect(pluginsFileContents.indexOf('plugin_a'), lessThan(pluginsFileContents.indexOf('plugin_b')));
|
||||
expect(pluginsFileContents.indexOf('plugin_b'), lessThan(pluginsFileContents.indexOf('plugin_c')));
|
||||
expect(pluginsFileContents.indexOf('plugin_c'), lessThan(pluginsFileContents.indexOf('plugin_d')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
|
Loading…
Reference in a new issue