Skip to content

Commit 6a1a9df

Browse files
alestiagoJochum van der Ploeg
andauthored
fix: support ignoring empty globs (#704)
Co-authored-by: Jochum van der Ploeg <jochum.vanderploeg@verygood.ventures>
1 parent b2ae22b commit 6a1a9df

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

lib/src/cli/cli.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension _Set on Set<String> {
176176
if (segments.intersection(this).isNotEmpty) return true;
177177

178178
for (final value in this) {
179-
if (Glob(value).matches(entity.path)) {
179+
if (value.isNotEmpty && Glob(value).matches(entity.path)) {
180180
return true;
181181
}
182182
}

test/src/commands/packages_test.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,56 @@ void main() {
270270
}),
271271
);
272272

273+
test(
274+
'completes normally '
275+
'''when pubspec.yaml exists and directory is not ignored (recursive) with an empty glob''',
276+
withRunner((commandRunner, logger, pubUpdater, printLogs) async {
277+
final tempDirectory = Directory.systemTemp.createTempSync();
278+
final directory = Directory(
279+
path.join(tempDirectory.path, 'macos_plugin'),
280+
);
281+
final pubspecA = File(
282+
path.join(directory.path, 'example_a', 'pubspec.yaml'),
283+
);
284+
final pubspecB = File(
285+
path.join(directory.path, 'example_b', 'pubspec.yaml'),
286+
);
287+
pubspecA
288+
..createSync(recursive: true)
289+
..writeAsStringSync(
290+
'''
291+
name: example_a
292+
version: 0.1.0
293+
294+
environment:
295+
sdk: ">=2.12.0 <3.0.0"
296+
''',
297+
);
298+
pubspecB
299+
..createSync(recursive: true)
300+
..writeAsStringSync(
301+
'''
302+
name: example_b
303+
version: 0.1.0
304+
305+
environment:
306+
sdk: ">=2.12.0 <3.0.0"
307+
''',
308+
);
309+
310+
final result = await commandRunner.run(
311+
['packages', 'get', '--recursive', directory.path, '--ignore=""'],
312+
);
313+
expect(result, equals(ExitCode.success.code));
314+
verify(() {
315+
logger.progress(
316+
any(that: contains('Running "flutter packages get" in')),
317+
);
318+
}).called(2);
319+
directory.deleteSync(recursive: true);
320+
}),
321+
);
322+
273323
test(
274324
'completes normally '
275325
'when pubspec.yaml exists and directory is ignored (recursive)',

0 commit comments

Comments
 (0)