Skip to content

Commit

Permalink
Merge pull request #366 from leoafarias/feature/support-older-dart-path
Browse files Browse the repository at this point in the history
Support for old dart path
  • Loading branch information
leoafarias authored Nov 12, 2021
2 parents c7ab46b + 3f5e09e commit 5bf2269
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Clean dart command output stdout [#361](https://github.com/leoafarias/fvm/issues/361)
- Better experience when running `dart pub cache repair` [#352](https://github.com/leoafarias/fvm/issues/352)
- Dart proxy points to correct path when version is older than 1.20.0 [#348](https://github.com/leoafarias/fvm/issues/348)

## 2.2.4

Expand Down
23 changes: 20 additions & 3 deletions lib/src/models/cache_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ class CacheVersion {

/// Get version bin path
String get binPath {
return join(dir.path, 'bin');
/// Get old bin path
/// Before version 1.17.5 dart path was bin/cache/dart-sdk/bin
if (hasOldBinPath) {
return join(dir.path, 'bin', 'cache', 'dart-sdk', 'bin');
} else {
return join(dir.path, 'bin');
}
}

/// Has old dart path structure
bool get hasOldBinPath {
// Last version with the old dart path structure
return compareSemver(versionWeight, '1.17.5') <= 0;
}

/// Returns dart exec file for cache version
Expand All @@ -41,9 +54,13 @@ class CacheVersion {

/// Compares CacheVersion with [other]
int compareTo(CacheVersion other) {
final version = assignVersionWeight(name);
final otherVersion = assignVersionWeight(other.name);
return compareSemver(version, otherVersion);
return compareSemver(versionWeight, otherVersion);
}

/// Returns true if CacheVersion is compatible with [other]
String get versionWeight {
return assignVersionWeight(name);
}

String toString() {
Expand Down

0 comments on commit 5bf2269

Please sign in to comment.