From 5db43aa5de499fd64a2872f287096cc71b667e0d Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Tue, 27 Feb 2024 08:38:59 -0500 Subject: [PATCH 1/2] Fix formatting and add default value for version in runDart function --- lib/src/commands/dart_command.dart | 5 ++--- lib/src/utils/commands.dart | 1 + lib/src/workflows/ensure_cache.workflow.dart | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/src/commands/dart_command.dart b/lib/src/commands/dart_command.dart index e0ddd4a1..44ab8975 100644 --- a/lib/src/commands/dart_command.dart +++ b/lib/src/commands/dart_command.dart @@ -35,11 +35,10 @@ class DartCommand extends BaseCommand { ..detail(''); } else { logger - ..detail('$kPackageName: Running Dart version configured in path.') + ..detail('$kPackageName: Running Dart version configured in PATH.') ..detail(''); - - // Running null will default to dart version on path } + // Running null will default to dart version on path final results = await runDart(args, version: cacheVersion); return results.exitCode; diff --git a/lib/src/utils/commands.dart b/lib/src/utils/commands.dart index ddf960dd..3966218c 100644 --- a/lib/src/utils/commands.dart +++ b/lib/src/utils/commands.dart @@ -38,6 +38,7 @@ Future runDart( bool? echoOutput, bool? throwOnError, }) { + version ??= GlobalVersionService.fromContext.getGlobal(); if (version == null) { return _runCmd(_dartCmd, args: args); } diff --git a/lib/src/workflows/ensure_cache.workflow.dart b/lib/src/workflows/ensure_cache.workflow.dart index 91bd62ae..6d5f1e00 100644 --- a/lib/src/workflows/ensure_cache.workflow.dart +++ b/lib/src/workflows/ensure_cache.workflow.dart @@ -37,12 +37,17 @@ Future ensureCacheWorkflow( ); } - if (integrity == CacheIntegrity.versionMismatch && !force && !validVersion.isCustom) { + if (integrity == CacheIntegrity.versionMismatch && + !force && + !validVersion.isCustom) { return await _handleVersionMismatch(cacheVersion); } else if (force) { - logger.warn('Not checking for version mismatch as --force flag is set.'); + logger + .warn('Not checking for version mismatch as --force flag is set.'); } else if (validVersion.isCustom) { - logger.warn('Not checking for version mismatch as custom version is being used.'); + logger.warn( + 'Not checking for version mismatch as custom version is being used.', + ); } // If shouldl install notifiy the user that is already installed @@ -165,7 +170,10 @@ Future _handleVersionMismatch( return ensureCacheWorkflow(version.name, shouldInstall: true); } -Future validateFlutterVersion(String version, {bool force = false}) async { +Future validateFlutterVersion( + String version, { + bool force = false, +}) async { final flutterVersion = FlutterVersion.parse(version); if (force) { From cc658fde0901936d6b2fa2cf4f44ffc938557d79 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Tue, 27 Feb 2024 08:40:14 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a253d0f..5bcb26c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## 3.0.12 +## Unreleased * Adds skipping version mismatch handling when using force or running with a custom fvm version. [#653](https://github.com/leoafarias/fvm/issues/653) * Fixes parsing error of vscode settings when there are commas [#656](https://github.com/leoafarias/fvm/issues/656) +* Sets global as first default if Dart SDK is not found in the project. ## 3.0.11