@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
10
10
import 'package:flutter_tools/src/cache.dart' ;
11
11
import 'package:flutter_tools/src/commands/packages.dart' ;
12
12
import 'package:flutter_tools/src/dart/pub.dart' ;
13
+ import 'package:flutter_tools/src/project.dart' ;
13
14
import 'package:flutter_tools/src/reporting/reporting.dart' ;
14
15
import 'package:meta/meta.dart' ;
15
16
import 'package:test/fake.dart' ;
@@ -77,6 +78,24 @@ void main() {
77
78
FileSystem : () => fileSystem,
78
79
});
79
80
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
+
80
99
testUsingContext ("pub get skips example directory if it doesn't contain a pubspec.yaml" , () async {
81
100
fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
82
101
fileSystem.currentDirectory.childDirectory ('example' ).createSync (recursive: true );
@@ -116,7 +135,7 @@ class FakePub extends Fake implements Pub {
116
135
bool shouldSkipThirdPartyGenerator = true ,
117
136
bool printProgress = true ,
118
137
}) async {
119
- fileSystem.currentDirectory
138
+ fileSystem.directory (directory)
120
139
.childDirectory ('.dart_tool' )
121
140
.childFile ('package_config.json' )
122
141
..createSync (recursive: true )
0 commit comments