Skip to content

Commit

Permalink
💚 Fix melos package script (#2354)
Browse files Browse the repository at this point in the history
https://pub.dev/packages/melos/versions/6.3.0/changelog

```console
scripts/melos_packages.dart:47:23: Error: The getter 'pubSpec' isn't defined for the class 'Package'.
 - 'Package' is from 'package:melos/src/package.dart' ('../../../.pub-cache/hosted/pub.dev/melos-6.3.1/lib/src/package.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'pubSpec'.
      .where((e) => e.pubSpec.environment!.sdkConstraint!.allows(current));
                      ^^^^^^^
```
  • Loading branch information
AlexV525 authored Jan 13, 2025
1 parent e7edb97 commit ffa1cc6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/melos_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ void main() async {
final current = Version.parse(
RegExp(r'\d*\.\d*\.\d*').firstMatch(Platform.version)!.group(0)!,
);
final validPackages = packages
.where((e) => e.pubSpec.environment!.sdkConstraint!.allows(current));
final validPackages = packages.where((e) {
final dynamic package = e as dynamic;
bool allows;
try {
// Compatible with melos v6.3.
allows = package.pubspec.environment['sdk']!.allows(current);
} on NoSuchMethodError {
// Fallback to previous melos.
allows = package.pubSpec.environment!.sdkConstraint!.allows(current);
}
return allows;
});

// Create melos marker files
for (final package in validPackages) {
Expand Down

0 comments on commit ffa1cc6

Please sign in to comment.