Skip to content

Commit

Permalink
fix: support ignoring empty globs (#704)
Browse files Browse the repository at this point in the history
Co-authored-by: Jochum van der Ploeg <jochum.vanderploeg@verygood.ventures>
  • Loading branch information
alestiago and wolfenrain committed Apr 12, 2023
1 parent b2ae22b commit 6a1a9df
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ extension _Set on Set<String> {
if (segments.intersection(this).isNotEmpty) return true;

for (final value in this) {
if (Glob(value).matches(entity.path)) {
if (value.isNotEmpty && Glob(value).matches(entity.path)) {
return true;
}
}
Expand Down
50 changes: 50 additions & 0 deletions test/src/commands/packages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,56 @@ void main() {
}),
);

test(
'completes normally '
'''when pubspec.yaml exists and directory is not ignored (recursive) with an empty glob''',
withRunner((commandRunner, logger, pubUpdater, printLogs) async {
final tempDirectory = Directory.systemTemp.createTempSync();
final directory = Directory(
path.join(tempDirectory.path, 'macos_plugin'),
);
final pubspecA = File(
path.join(directory.path, 'example_a', 'pubspec.yaml'),
);
final pubspecB = File(
path.join(directory.path, 'example_b', 'pubspec.yaml'),
);
pubspecA
..createSync(recursive: true)
..writeAsStringSync(
'''
name: example_a
version: 0.1.0
environment:
sdk: ">=2.12.0 <3.0.0"
''',
);
pubspecB
..createSync(recursive: true)
..writeAsStringSync(
'''
name: example_b
version: 0.1.0
environment:
sdk: ">=2.12.0 <3.0.0"
''',
);

final result = await commandRunner.run(
['packages', 'get', '--recursive', directory.path, '--ignore=""'],
);
expect(result, equals(ExitCode.success.code));
verify(() {
logger.progress(
any(that: contains('Running "flutter packages get" in')),
);
}).called(2);
directory.deleteSync(recursive: true);
}),
);

test(
'completes normally '
'when pubspec.yaml exists and directory is ignored (recursive)',
Expand Down

0 comments on commit 6a1a9df

Please sign in to comment.