diff --git a/packages/nx-flutter/src/graph/plugin.ts b/packages/nx-flutter/src/graph/plugin.ts index 3cbb4604..f64a2a9b 100644 --- a/packages/nx-flutter/src/graph/plugin.ts +++ b/packages/nx-flutter/src/graph/plugin.ts @@ -1,4 +1,7 @@ +import { isFlutterInstalled } from '../utils/flutter-utils'; + export interface NxFlutterPluginOptions { + useFvm?: boolean; analyzeTargetName?: string; cleanTargetName?: string; formatTargetName?: string; @@ -23,8 +26,11 @@ export function normalizePluginOptions( opts?: NxFlutterPluginOptions ): NxFlutterPluginOptions { const options = opts ?? {}; + const isFvmInstalled = isFlutterInstalled(true); + return { ...options, + useFvm: options.useFvm && isFvmInstalled, analyzeTargetName: options.analyzeTargetName ?? 'analyze', cleanTargetName: options.cleanTargetName ?? 'clean', formatTargetName: options.formatTargetName ?? 'format', diff --git a/packages/nx-flutter/src/utils/plugin-utils.ts b/packages/nx-flutter/src/utils/plugin-utils.ts index f9b34d35..0d9ee9f2 100644 --- a/packages/nx-flutter/src/utils/plugin-utils.ts +++ b/packages/nx-flutter/src/utils/plugin-utils.ts @@ -23,7 +23,6 @@ export function getProjectTypeAndTargetsFromFile( const platforms: PlatformType[] = []; let template: TemplateType = 'app'; - const useFvm = isFlutterInstalled(true); if (hasProjectFile({ root }, 'android')) platforms.push('android'); if (hasProjectFile({ root }, 'ios')) platforms.push('ios'); @@ -43,7 +42,6 @@ export function getProjectTypeAndTargetsFromFile( root, template, platforms, - useFvm, normalizePluginOptions(pluginOptions) ); } @@ -53,8 +51,7 @@ export function getProjectTypeAndTargetsFromOptions(options: NormalizedSchema) { options.projectRoot, options.template, options.platforms, - options.useFvm, - normalizePluginOptions() + normalizePluginOptions({ useFvm: options.useFvm }) ); } @@ -62,7 +59,6 @@ function getProjectTypeAndTargets( projectRoot: string, template: TemplateType, platforms: PlatformType[], - useFvm: boolean, pluginOptions: NxFlutterPluginOptions ) { const targets = {}; @@ -115,7 +111,7 @@ function getProjectTypeAndTargets( command: `${ command.key === pluginOptions.formatTargetName ? 'dart' - : `${useFvm === true ? 'fvm ' : ''}flutter` + : `${pluginOptions.useFvm === true ? 'fvm ' : ''}flutter` } ${command.value}`, cwd: projectRoot, },