Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.

Commit f701e7f

Browse files
committed
Fix dependencies
1 parent 699a9ed commit f701e7f

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

lib/src/core/src/paths.dart

+37-17
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ import 'package:path/path.dart' as p;
1414

1515
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1616

17-
/// Returns the base name of a given file path.
17+
/// Returns the base name of a given file [path].
1818
String getBaseName(String path) {
1919
final localSystemFilePath = toLocalSystemPathFormat(path);
2020
return p.basename(localSystemFilePath);
2121
}
2222

23-
/// Returns the directory path of a given file path.
23+
/// Returns the directory path of a given file [path].
2424
String getDirPath(String path) {
2525
final localSystemFilePath = toLocalSystemPathFormat(path);
2626
return p.dirname(localSystemFilePath);
2727
}
2828

29-
/// Checks if the provided path contains any of the specified components. This
30-
/// operation is case-insensitive.
29+
/// Checks if the provided [path] contains any of the specified [components].
30+
/// This operation is case-insensitive.
3131
bool pathContainsComponent(String path, Set<String> components) {
3232
final localSystemFilePath = toLocalSystemPathFormat(path);
3333
final a = p.split(localSystemFilePath).map((e) => e.toLowerCase());
@@ -39,7 +39,7 @@ bool pathContainsComponent(String path, Set<String> components) {
3939
return false;
4040
}
4141

42-
/// Checks if the provided path matches any of the specified path patterns.
42+
/// Checks if the provided [path] matches any of the specified [pathPatterns].
4343
bool matchesAnyPathPattern(String path, Set<String> pathPatterns) {
4444
if (pathPatterns.isNotEmpty) {
4545
final localSystemFilePath = toLocalSystemPathFormat(path);
@@ -51,48 +51,68 @@ bool matchesAnyPathPattern(String path, Set<String> pathPatterns) {
5151
return true;
5252
}
5353

54-
/// Converts the given path to a consistent, local path format.
54+
/// Checks if the provided [filePath] matches any of the specified [extensions].
55+
///
56+
/// Notes:
57+
///
58+
/// - If the [extensions] set is empty, the function will return true.
59+
/// - Specify [caseSensitive] as false to ignore case.
60+
bool matchesAnyExtension(
61+
String filePath,
62+
Set<String> extensions, {
63+
bool caseSensitive = true,
64+
}) {
65+
if (extensions.isEmpty) return true;
66+
final extension = p.extension(filePath);
67+
return extensions.any((e) {
68+
final a = caseSensitive ? extension : extension.toLowerCase();
69+
final b = caseSensitive ? e : e.toLowerCase();
70+
return a == b;
71+
});
72+
}
73+
74+
/// Converts the given [filePath] to a consistent, local path format.
5575
String getFileNameWithoutExtension(String filePath) {
5676
final localSystemFilePath = toLocalSystemPathFormat(filePath);
5777
return p.basenameWithoutExtension(localSystemFilePath);
5878
}
5979

60-
/// Replaces all forward slashes with the local path separator.
80+
/// Replaces all forward slashes in [path] with the local path separator.
6181
String toLocalSystemPathFormat(String path) {
6282
return path.split(RegExp(r'[\\/]')).join(p.separator);
6383
}
6484

65-
/// Replaces all backslashes with forward slashes.
85+
/// Replaces all backslashes in [path] with forward slashes.
6686
String toUnixSystemPathFormat(String path) {
6787
return path.split(RegExp(r'[\\/]')).join('/');
6888
}
6989

70-
/// Replaces all forward slashes with backslashes.
90+
/// Replaces all forward slashes in [path] with backslashes.
7191
String toWindowsSystemPathFormat(String path) {
7292
return path.split(RegExp(r'[\\/]')).join('\\');
7393
}
7494

75-
/// Checks if the provided file is a private Dart file (starts with an
95+
/// Checks if the provided [filePath] is a private file (starts with an
7696
/// underscore).
7797
bool isPrivateFileName(String filePath) {
7898
final fileName = getBaseName(filePath);
7999
return fileName.startsWith('_');
80100
}
81101

82-
/// Checks if the file name matches the specified beginning and ending types.
102+
/// Checks if the file name extracted from [filePath] matches the specified
103+
/// beginning type [begType] and ending type [endType].
104+
///
83105
/// Returns a tuple with the match status and the file name.
84-
(bool, String) isMatchingFileName(
106+
({bool status, String fileName}) isMatchingFileName(
85107
String filePath,
86108
String begType,
87109
String endType,
88110
) {
89111
final fileName = getBaseName(filePath);
90-
final a =
91-
begType.isEmpty ? true : fileName.startsWith('${begType.toLowerCase()}_');
92-
final b =
93-
endType.isEmpty ? true : fileName.endsWith('.$endType'.toLowerCase());
112+
final a = begType.isEmpty ? true : fileName.startsWith('${begType.toLowerCase()}_');
113+
final b = endType.isEmpty ? true : fileName.endsWith('.$endType'.toLowerCase());
94114
final c = a && b;
95-
return (c, fileName);
115+
return (status: c, fileName: fileName);
96116
}
97117

98118
/// Combines multiple [pathSets] into a single set, returning all possible

lib/xyz_utils_non_web.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
library;
1414

15-
export 'xyz_utils_any_platform.dart';
15+
export 'xyz_utils.dart';
1616

1717
export '/src_non_web/_all_src_non_web.g.dart';
18-
export '/src/_all_src.g.dart';

0 commit comments

Comments
 (0)