diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6556c9..df31fa50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/src/models/cache_version_model.dart b/lib/src/models/cache_version_model.dart index b334b54f..347d49f3 100644 --- a/lib/src/models/cache_version_model.dart +++ b/lib/src/models/cache_version_model.dart @@ -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 @@ -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() {