@@ -94,6 +94,32 @@ void main() {
9494 FileSystem : () => fileSystem,
9595 });
9696
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+
97123 testUsingContext ("pub get skips example directory if it doesn't contain a pubspec.yaml" , () async {
98124 fileSystem.currentDirectory.childFile ('pubspec.yaml' ).createSync ();
99125 fileSystem.currentDirectory.childDirectory ('example' ).createSync (recursive: true );
@@ -181,6 +207,7 @@ class FakePub extends Fake implements Pub {
181207 FakePub (this .fileSystem);
182208
183209 final FileSystem fileSystem;
210+ List <String >? expectedArguments;
184211
185212 @override
186213 Future <void > interactively (
@@ -192,6 +219,9 @@ class FakePub extends Fake implements Pub {
192219 bool generateSyntheticPackage = false ,
193220 PubOutputMode outputMode = PubOutputMode .all,
194221 }) async {
222+ if (expectedArguments != null ) {
223+ expect (arguments, expectedArguments);
224+ }
195225 if (project != null ) {
196226 fileSystem.directory (project.directory)
197227 .childDirectory ('.dart_tool' )
0 commit comments