Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(packages_get): recursive installation ignored directories fixes #283

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,21 @@ class _Cmd {
}
}

final _ignoredDirectories = RegExp(
'ios|android|windows|linux|macos|.symlinks|.plugin_symlinks|.dart_tool|build',
);
const _ignoredDirectories = {
'ios',
'android',
'windows',
'linux',
'macos',
'.symlinks',
'.plugin_symlinks',
'.dart_tool',
'build',
};

bool _isPubspec(FileSystemEntity entity) {
if (entity.path.contains(_ignoredDirectories)) return false;
final segments = p.split(entity.path).toSet();
if (segments.intersection(_ignoredDirectories).isNotEmpty) return false;
if (entity is! File) return false;
return p.basename(entity.path) == 'pubspec.yaml';
}
48 changes: 48 additions & 0 deletions test/src/commands/packages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,54 @@ void main() {
);
}).called(2);
});

test(
'completes normally '
'when pubspec.yaml exists and directory is not ignored (recursive)',
() 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],
);
expect(result, equals(ExitCode.success.code));
verify(() {
logger.progress(
any(that: contains('Running "flutter packages get" in')),
);
}).called(2);
});
});
});
}