mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 13:38:53 +08:00
[tool] Allow running from anywhere (#4199)
Now that the repo tooling is always run from source, not via `pub global`, we no longer need to infer the repo location from the current directory. Instead, hard-code knowledge of where the repository root is. This makes it much easier to run the tooling, since it's common to be in a package directory rather than the repo root. To make it even easier to run from within a package, this also adds a `--current-package` as an alternative to `--packages`. This makes it possible to, e.g., write local wrapper scripts that run a specific set of commands on whatever the current package happens to be (such as a generic version of the script discussed in https://github.com/flutter/packages/pull/4129). As related cleanup, makes the tool non-publishable (we haven't been publishing it since the repo merge, but I never made it unpublishable; this is important now that it would not work if published) and remove the LICENSE and CHANGELOG since it's no longer a stand-alone package. Fixes https://github.com/flutter/flutter/issues/128231 Fixes https://github.com/flutter/flutter/issues/128232
This commit is contained in:
@ -41,17 +41,14 @@ import 'xcode_analyze_command.dart';
|
||||
|
||||
void main(List<String> args) {
|
||||
const FileSystem fileSystem = LocalFileSystem();
|
||||
|
||||
Directory packagesDir =
|
||||
fileSystem.currentDirectory.childDirectory('packages');
|
||||
final Directory scriptBinDir =
|
||||
fileSystem.file(io.Platform.script.toFilePath()).parent;
|
||||
final Directory root = scriptBinDir.parent.parent.parent;
|
||||
final Directory packagesDir = root.childDirectory('packages');
|
||||
|
||||
if (!packagesDir.existsSync()) {
|
||||
if (fileSystem.currentDirectory.basename == 'packages') {
|
||||
packagesDir = fileSystem.currentDirectory;
|
||||
} else {
|
||||
print('Error: Cannot find a "packages" sub-directory');
|
||||
io.exit(1);
|
||||
}
|
||||
print('Error: Cannot find a "packages" sub-directory');
|
||||
io.exit(1);
|
||||
}
|
||||
|
||||
final CommandRunner<void> commandRunner = CommandRunner<void>(
|
||||
|
Reference in New Issue
Block a user