@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
1010import 'package:flutter_tools/src/cache.dart' ;
1111import 'package:flutter_tools/src/commands/packages.dart' ;
1212import 'package:flutter_tools/src/dart/pub.dart' ;
13+ import 'package:flutter_tools/src/project.dart' ;
1314import 'package:flutter_tools/src/reporting/reporting.dart' ;
1415import 'package:meta/meta.dart' ;
1516import 'package:test/fake.dart' ;
@@ -77,6 +78,24 @@ void main() {
7778 FileSystem : () => fileSystem,
7879 });
7980
81+ testUsingContext ('pub get on target directory' , () async {
82+ fileSystem.currentDirectory.childDirectory ('target' ).createSync ();
83+ final Directory targetDirectory = fileSystem.currentDirectory.childDirectory ('target' );
84+ targetDirectory.childFile ('pubspec.yaml' ).createSync ();
85+
86+ final PackagesGetCommand command = PackagesGetCommand ('get' , false );
87+ final CommandRunner <void > commandRunner = createTestCommandRunner (command);
88+
89+ await commandRunner.run (< String > ['get' , targetDirectory.path]);
90+ final FlutterProject rootProject = FlutterProject .fromDirectory (targetDirectory);
91+ expect (rootProject.packageConfigFile.existsSync (), true );
92+ expect (await rootProject.packageConfigFile.readAsString (), '{"configVersion":2,"packages":[]}' );
93+ }, overrides: < Type , Generator > {
94+ Pub : () => pub,
95+ ProcessManager : () => FakeProcessManager .any (),
96+ FileSystem : () => fileSystem,
97+ });
98+
8099 testUsingContext ("pub get skips example directory if it doesn't contain a pubspec.yaml" , () async {
81100 fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
82101 fileSystem.currentDirectory.childDirectory ('example' ).createSync (recursive: true );
@@ -116,7 +135,7 @@ class FakePub extends Fake implements Pub {
116135 bool shouldSkipThirdPartyGenerator = true ,
117136 bool printProgress = true ,
118137 }) async {
119- fileSystem.currentDirectory
138+ fileSystem.directory (directory)
120139 .childDirectory ('.dart_tool' )
121140 .childFile ('package_config.json' )
122141 ..createSync (recursive: true )
0 commit comments