[flutter_tools] Don't try to run pub before the version command (#51436)
This commit is contained in:
@@ -17,11 +17,17 @@ import '../version.dart';
|
||||
|
||||
class VersionCommand extends FlutterCommand {
|
||||
VersionCommand() : super() {
|
||||
usesPubOption(hide: true);
|
||||
argParser.addFlag('force',
|
||||
abbr: 'f',
|
||||
help: 'Force switch to older Flutter versions that do not include a version command',
|
||||
);
|
||||
// Don't use usesPubOption here. That will cause the version command to
|
||||
// require a pubspec.yaml file, which it doesn't need.
|
||||
argParser.addFlag('pub',
|
||||
defaultsTo: true,
|
||||
hide: true,
|
||||
help: 'Whether to run "flutter pub get" after switching versions.',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -138,7 +144,7 @@ class VersionCommand extends FlutterCommand {
|
||||
globals.printStatus(flutterVersion.toString());
|
||||
|
||||
final String projectRoot = findProjectRoot();
|
||||
if (projectRoot != null && shouldRunPub) {
|
||||
if (projectRoot != null && boolArg('pub')) {
|
||||
globals.printStatus('');
|
||||
await pub.get(
|
||||
context: PubContext.pubUpgrade,
|
||||
|
||||
Reference in New Issue
Block a user