mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
(cleanup) standardize on shouldRunPub and usesPubOptions() in commands (#13427)
This commit is contained in:
parent
71021b4706
commit
9315a79b11
@ -28,10 +28,7 @@ import '../version.dart';
|
|||||||
|
|
||||||
class CreateCommand extends FlutterCommand {
|
class CreateCommand extends FlutterCommand {
|
||||||
CreateCommand() {
|
CreateCommand() {
|
||||||
argParser.addFlag('pub',
|
usesPubOption();
|
||||||
defaultsTo: true,
|
|
||||||
help: 'Whether to run "flutter packages get" after the project has been created.'
|
|
||||||
);
|
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
'with-driver-test',
|
'with-driver-test',
|
||||||
negatable: true,
|
negatable: true,
|
||||||
@ -161,7 +158,7 @@ class CreateCommand extends FlutterCommand {
|
|||||||
templateContext['description'] = description;
|
templateContext['description'] = description;
|
||||||
generatedCount += _renderTemplate('package', dirPath, templateContext);
|
generatedCount += _renderTemplate('package', dirPath, templateContext);
|
||||||
|
|
||||||
if (argResults['pub'])
|
if (shouldRunPub)
|
||||||
await pubGet(context: PubContext.createPackage, directory: dirPath);
|
await pubGet(context: PubContext.createPackage, directory: dirPath);
|
||||||
|
|
||||||
final String relativePath = fs.path.relative(dirPath);
|
final String relativePath = fs.path.relative(dirPath);
|
||||||
@ -179,7 +176,7 @@ class CreateCommand extends FlutterCommand {
|
|||||||
templateContext['description'] = description;
|
templateContext['description'] = description;
|
||||||
generatedCount += _renderTemplate('plugin', dirPath, templateContext);
|
generatedCount += _renderTemplate('plugin', dirPath, templateContext);
|
||||||
|
|
||||||
if (argResults['pub'])
|
if (shouldRunPub)
|
||||||
await pubGet(context: PubContext.createPlugin, directory: dirPath);
|
await pubGet(context: PubContext.createPlugin, directory: dirPath);
|
||||||
|
|
||||||
if (android_sdk.androidSdk != null)
|
if (android_sdk.androidSdk != null)
|
||||||
@ -217,7 +214,7 @@ class CreateCommand extends FlutterCommand {
|
|||||||
previewDart2: false,
|
previewDart2: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (argResults['pub']) {
|
if (shouldRunPub) {
|
||||||
await pubGet(context: PubContext.create, directory: appPath);
|
await pubGet(context: PubContext.create, directory: appPath);
|
||||||
injectPlugins(directory: appPath);
|
injectPlugins(directory: appPath);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ abstract class FlutterCommand extends Command<Null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate the current package map only if we will not be running "pub get" later.
|
// Validate the current package map only if we will not be running "pub get" later.
|
||||||
if (parent?.name != 'packages' && !(_usesPubOption && argResults['pub'])) {
|
if (parent?.name != 'packages' && !shouldRunPub) {
|
||||||
final String error = new PackageMap(PackageMap.globalPackagesPath).checkValid();
|
final String error = new PackageMap(PackageMap.globalPackagesPath).checkValid();
|
||||||
if (error != null)
|
if (error != null)
|
||||||
throw new ToolExit(error);
|
throw new ToolExit(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user