Skip to content

Commit

Permalink
Merge pull request #286 from leoafarias/fix/285
Browse files Browse the repository at this point in the history
Passes bin path instead of exec
  • Loading branch information
leoafarias authored May 4, 2021
2 parents c0481b9 + 3fa5348 commit 7f72a03
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
9 changes: 7 additions & 2 deletions lib/src/models/cache_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions lib/src/utils/commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ Future<int> flutterCmd(
CacheVersion version,
List<String> 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,
);
Expand Down
14 changes: 7 additions & 7 deletions lib/src/utils/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ Future<void> createLink(Link source, FileSystemEntity target) async {
}

/// Returns updated environment for Flutter with [execPath]
Map<String, String> updateFlutterEnvVariables(String execPath) {
return _updateEnvVariables('flutter', execPath);
Map<String, String> updateFlutterEnvVariables(String binPath) {
return _updateEnvVariables('flutter', binPath);
}

/// Returns updated environment for Dark with [execPath]
Map<String, String> updateDartEnvVariables(String execPath) {
return _updateEnvVariables('dart', execPath);
/// Returns updated environment for Dark with [binPath]
Map<String, String> updateDartEnvVariables(String binPath) {
return _updateEnvVariables('dart', binPath);
}

Map<String, String> _updateEnvVariables(
String key,
String execPath,
String binPath,
) {
final envPath = kEnvVars['PATH'] ?? '';

Expand All @@ -92,7 +92,7 @@ Map<String, String> _updateEnvVariables(
final newEnv = pathEnvList.join(':');

return Map<String, String>.from(kEnvVars)
..addAll({'PATH': '$newEnv:$execPath'});
..addAll({'PATH': '$newEnv:$binPath'});
}

/// Compares a [version] against [other]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 7f72a03

Please sign in to comment.