mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 22:03:33 +08:00
[flutter_plugin_tools] Simplify filesystem usage (#4014)
- Replaces most explicit use of `fileSystem` with path construction using the `child*` utility methods - Removes explicit passing of a filesystem to the commands; we're already passing a `Directory` for the root where the tool operates, and we should never be using a different filesystem than that directory's filesystem, so passing it was both redundant, and a potential source of test bugs.
This commit is contained in:
@ -9,7 +9,6 @@ import 'dart:io' as io;
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/local.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'analyze_command.dart';
|
||||
import 'build_examples_command.dart';
|
||||
@ -32,11 +31,11 @@ import 'xctest_command.dart';
|
||||
void main(List<String> args) {
|
||||
const FileSystem fileSystem = LocalFileSystem();
|
||||
|
||||
Directory packagesDir = fileSystem
|
||||
.directory(p.join(fileSystem.currentDirectory.path, 'packages'));
|
||||
Directory packagesDir =
|
||||
fileSystem.currentDirectory.childDirectory('packages');
|
||||
|
||||
if (!packagesDir.existsSync()) {
|
||||
if (p.basename(fileSystem.currentDirectory.path) == 'packages') {
|
||||
if (fileSystem.currentDirectory.basename == 'packages') {
|
||||
packagesDir = fileSystem.currentDirectory;
|
||||
} else {
|
||||
print('Error: Cannot find a "packages" sub-directory');
|
||||
@ -47,22 +46,22 @@ void main(List<String> args) {
|
||||
final CommandRunner<void> commandRunner = CommandRunner<void>(
|
||||
'pub global run flutter_plugin_tools',
|
||||
'Productivity utils for hosting multiple plugins within one repository.')
|
||||
..addCommand(AnalyzeCommand(packagesDir, fileSystem))
|
||||
..addCommand(BuildExamplesCommand(packagesDir, fileSystem))
|
||||
..addCommand(CreateAllPluginsAppCommand(packagesDir, fileSystem))
|
||||
..addCommand(DriveExamplesCommand(packagesDir, fileSystem))
|
||||
..addCommand(FirebaseTestLabCommand(packagesDir, fileSystem))
|
||||
..addCommand(FormatCommand(packagesDir, fileSystem))
|
||||
..addCommand(JavaTestCommand(packagesDir, fileSystem))
|
||||
..addCommand(LicenseCheckCommand(packagesDir, fileSystem))
|
||||
..addCommand(LintPodspecsCommand(packagesDir, fileSystem))
|
||||
..addCommand(ListCommand(packagesDir, fileSystem))
|
||||
..addCommand(PublishCheckCommand(packagesDir, fileSystem))
|
||||
..addCommand(PublishPluginCommand(packagesDir, fileSystem))
|
||||
..addCommand(PubspecCheckCommand(packagesDir, fileSystem))
|
||||
..addCommand(TestCommand(packagesDir, fileSystem))
|
||||
..addCommand(VersionCheckCommand(packagesDir, fileSystem))
|
||||
..addCommand(XCTestCommand(packagesDir, fileSystem));
|
||||
..addCommand(AnalyzeCommand(packagesDir))
|
||||
..addCommand(BuildExamplesCommand(packagesDir))
|
||||
..addCommand(CreateAllPluginsAppCommand(packagesDir))
|
||||
..addCommand(DriveExamplesCommand(packagesDir))
|
||||
..addCommand(FirebaseTestLabCommand(packagesDir))
|
||||
..addCommand(FormatCommand(packagesDir))
|
||||
..addCommand(JavaTestCommand(packagesDir))
|
||||
..addCommand(LicenseCheckCommand(packagesDir))
|
||||
..addCommand(LintPodspecsCommand(packagesDir))
|
||||
..addCommand(ListCommand(packagesDir))
|
||||
..addCommand(PublishCheckCommand(packagesDir))
|
||||
..addCommand(PublishPluginCommand(packagesDir))
|
||||
..addCommand(PubspecCheckCommand(packagesDir))
|
||||
..addCommand(TestCommand(packagesDir))
|
||||
..addCommand(VersionCheckCommand(packagesDir))
|
||||
..addCommand(XCTestCommand(packagesDir));
|
||||
|
||||
commandRunner.run(args).catchError((Object e) {
|
||||
final ToolExit toolExit = e as ToolExit;
|
||||
|
Reference in New Issue
Block a user