Skip to content

Commit

Permalink
Fix SDK-detection in pub_worker. (#6776)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Jun 21, 2023
1 parent 5b5faea commit b10596d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/pub_worker/lib/src/sdks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ class InstalledSdk {
continue;
}
try {
// all SDKs have bin/ directory
final binDir = Directory(p.join(d.path, 'bin'));
if (!(await binDir.exists())) {
continue;
}
// only Dart SDK has lib/
// only Flutter SDK has packages/
if (kind == 'dart') {
final libDir = Directory(p.join(d.path, 'lib'));
if (!(await libDir.exists())) {
continue;
}
} else if (kind == 'flutter') {
final packagesDir = Directory(p.join(d.path, 'packages'));
if (!(await packagesDir.exists())) {
continue;
}
}

final v = await File(p.join(d.path, 'version')).readAsString();
sdks.add(InstalledSdk(kind, d.path, Version.parse(v.trim())));
} on FormatException {
Expand Down

0 comments on commit b10596d

Please sign in to comment.