@@ -94,6 +94,32 @@ void main() {
94
94
FileSystem : () => fileSystem,
95
95
});
96
96
97
+ testUsingContext ("pub get doesn't treat unknown flag as directory" , () async {
98
+ fileSystem.currentDirectory.childDirectory ('target' ).createSync ();
99
+ fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
100
+ final PackagesGetCommand command = PackagesGetCommand ('get' , '' , PubContext .pubGet);
101
+ final CommandRunner <void > commandRunner = createTestCommandRunner (command);
102
+ pub.expectedArguments = < String > ['get' , '--unknown-flag' , '--example' , '--directory' , '.' ];
103
+ await commandRunner.run (< String > ['get' , '--unknown-flag' ]);
104
+ }, overrides: < Type , Generator > {
105
+ Pub : () => pub,
106
+ ProcessManager : () => FakeProcessManager .any (),
107
+ FileSystem : () => fileSystem,
108
+ });
109
+
110
+ testUsingContext ("pub get doesn't treat -v as directory" , () async {
111
+ fileSystem.currentDirectory.childDirectory ('target' ).createSync ();
112
+ fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
113
+ final PackagesGetCommand command = PackagesGetCommand ('get' , '' , PubContext .pubGet);
114
+ final CommandRunner <void > commandRunner = createTestCommandRunner (command);
115
+ pub.expectedArguments = < String > ['get' , '-v' , '--example' , '--directory' , '.' ];
116
+ await commandRunner.run (< String > ['get' , '-v' ]);
117
+ }, overrides: < Type , Generator > {
118
+ Pub : () => pub,
119
+ ProcessManager : () => FakeProcessManager .any (),
120
+ FileSystem : () => fileSystem,
121
+ });
122
+
97
123
testUsingContext ("pub get skips example directory if it doesn't contain a pubspec.yaml" , () async {
98
124
fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
99
125
fileSystem.currentDirectory.childDirectory ('example' ).createSync (recursive: true );
@@ -181,6 +207,7 @@ class FakePub extends Fake implements Pub {
181
207
FakePub (this .fileSystem);
182
208
183
209
final FileSystem fileSystem;
210
+ List <String >? expectedArguments;
184
211
185
212
@override
186
213
Future <void > interactively (
@@ -192,6 +219,9 @@ class FakePub extends Fake implements Pub {
192
219
bool generateSyntheticPackage = false ,
193
220
PubOutputMode outputMode = PubOutputMode .all,
194
221
}) async {
222
+ if (expectedArguments != null ) {
223
+ expect (arguments, expectedArguments);
224
+ }
195
225
if (project != null ) {
196
226
fileSystem.directory (project.directory)
197
227
.childDirectory ('.dart_tool' )
0 commit comments