Skip to content

Commit 6d2e866

Browse files
committed
feat(fvm): support FVM in monorepo setup
As pointed in https://fvm.app/documentation/getting-started/faq#monorepo-support FVM could be set at the root of monorepo.
1 parent 01d72d9 commit 6d2e866

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lua/flutter-tools/executable.lua

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local config = lazy.require("flutter-tools.config") ---@module "flutter-tools.co
66
local Job = require("plenary.job")
77

88
local fn = vim.fn
9+
local fs = vim.fs
910
local luv = vim.loop
1011

1112
local M = {}
@@ -98,15 +99,22 @@ local function path_from_lookup_cmd(lookup_cmd, callback)
9899
job:start()
99100
end
100101

102+
local function _flutter_bin_from_fvm()
103+
local fvm_root =
104+
fs.dirname(fs.find(".fvm", { path = luv.cwd(), upward = true, type = "directory" })[1])
105+
local flutter_bin_symlink = path.join(fvm_root, ".fvm", "flutter_sdk", "bin", "flutter")
106+
local flutter_bin = luv.fs_realpath(flutter_bin_symlink)
107+
if path.exists(flutter_bin_symlink) and path.exists(flutter_bin) then return flutter_bin end
108+
end
109+
101110
---Fetch the paths to the users binaries.
102111
---@param callback fun(paths: table<string, string>)
103112
---@return nil
104113
function M.get(callback)
105114
if _paths then return callback(_paths) end
106115
if config.fvm then
107-
local flutter_bin_symlink = path.join(luv.cwd(), ".fvm", "flutter_sdk", "bin", "flutter")
108-
local flutter_bin = luv.fs_realpath(flutter_bin_symlink)
109-
if path.exists(flutter_bin_symlink) and path.exists(flutter_bin) then
116+
local flutter_bin = _flutter_bin_from_fvm()
117+
if flutter_bin then
110118
_paths = {
111119
flutter_bin = flutter_bin,
112120
flutter_sdk = _flutter_sdk_root(flutter_bin),

0 commit comments

Comments
 (0)