getSpmSourcesDirs function

List<String> getSpmSourcesDirs(
  1. String packageSwiftPath
)

Gets the Sources directories from a Package.swift.

Implementation

List<String> getSpmSourcesDirs(String packageSwiftPath) {
  final file = File(packageSwiftPath);
  if (!file.existsSync()) return [];

  final content = file.readAsStringSync();
  final dirs = <String>[];

  // Match path: "Sources/Xxx" patterns
  final pathPattern = RegExp(r'path:\s*"(Sources/[^"]+)"');
  for (final match in pathPattern.allMatches(content)) {
    dirs.add(match.group(1)!);
  }

  return dirs;
}