From 3fa5348f25dfd448e7ec09bd16b65481f36362d1 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Tue, 4 May 2021 08:19:20 -0400 Subject: [PATCH] Passes bin path instead of exec --- CHANGELOG.md | 4 ++++ lib/src/models/cache_version_model.dart | 9 +++++++-- lib/src/utils/commands.dart | 7 ++----- lib/src/utils/helpers.dart | 14 +++++++------- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bf80725..62b0b89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.3 + +- Fixes monorepo compatibility [#285](https://github.com/leoafarias/fvm/issues/285) + ## 2.0.2 - Fixes regression when running `fvm install` diff --git a/lib/src/models/cache_version_model.dart b/lib/src/models/cache_version_model.dart index 6f46b5f4..b334b54f 100644 --- a/lib/src/models/cache_version_model.dart +++ b/lib/src/models/cache_version_model.dart @@ -14,14 +14,19 @@ class CacheVersion { /// Constructor CacheVersion(this.name); + /// Get version bin path + String get binPath { + return join(dir.path, 'bin'); + } + /// Returns dart exec file for cache version String get dartExec { - return join(dir.path, 'bin', dartBinFileName); + return join(binPath, dartBinFileName); } /// Returns flutter exec file for cache version String get flutterExec { - return join(dir.path, 'bin', flutterBinFileName); + return join(binPath, flutterBinFileName); } /// Returns CacheVersion directory diff --git a/lib/src/utils/commands.dart b/lib/src/utils/commands.dart index b0b4b4e6..76e80a68 100644 --- a/lib/src/utils/commands.dart +++ b/lib/src/utils/commands.dart @@ -16,14 +16,11 @@ Future flutterCmd( CacheVersion version, List args, ) async { - // Get exec path for flutter - final execPath = version.flutterExec; - // Update environment variables - final environment = updateFlutterEnvVariables(execPath); + final environment = updateFlutterEnvVariables(version.binPath); // Run command return await _runCmd( - execPath, + version.flutterExec, args: args, environment: environment, ); diff --git a/lib/src/utils/helpers.dart b/lib/src/utils/helpers.dart index d763e78d..c6b12eae 100644 --- a/lib/src/utils/helpers.dart +++ b/lib/src/utils/helpers.dart @@ -66,18 +66,18 @@ Future createLink(Link source, FileSystemEntity target) async { } /// Returns updated environment for Flutter with [execPath] -Map updateFlutterEnvVariables(String execPath) { - return _updateEnvVariables('flutter', execPath); +Map updateFlutterEnvVariables(String binPath) { + return _updateEnvVariables('flutter', binPath); } -/// Returns updated environment for Dark with [execPath] -Map updateDartEnvVariables(String execPath) { - return _updateEnvVariables('dart', execPath); +/// Returns updated environment for Dark with [binPath] +Map updateDartEnvVariables(String binPath) { + return _updateEnvVariables('dart', binPath); } Map _updateEnvVariables( String key, - String execPath, + String binPath, ) { final envPath = kEnvVars['PATH'] ?? ''; @@ -92,7 +92,7 @@ Map _updateEnvVariables( final newEnv = pathEnvList.join(':'); return Map.from(kEnvVars) - ..addAll({'PATH': '$newEnv:$execPath'}); + ..addAll({'PATH': '$newEnv:$binPath'}); } /// Compares a [version] against [other] diff --git a/lib/src/version.dart b/lib/src/version.dart index 57ef5ad5..170650cf 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '2.0.2'; +const packageVersion = '2.0.3'; diff --git a/pubspec.yaml b/pubspec.yaml index 07e697e9..e768d71e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fvm description: A simple cli to manage Flutter SDK versions per project. Support channels, releases, and local cache for fast switching between versions. -version: 2.0.2 +version: 2.0.3 homepage: https://github.com/leoafarias/fvm environment: