Skip to content

prefer the dart binary located in dart_sdk rather than flutter_sdk #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lua/flutter-tools/executable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ local function _dart_sdk_root(paths)
return path.join(flutter_bin, dart_sdk)
end

if utils.executable("dart") then return fn.resolve(fn.exepath("dart")) end
if utils.executable("dart") then return fn.resolve(path.dirname(path.dirname(fn.exepath("dart")))) end

return ""
end

local function _flutter_sdk_dart_bin(flutter_sdk)
-- retrieve the Dart binary from the Flutter SDK
local function _sdk_dart_bin(paths)
-- retrieve the Dart binary from the Dart SDK or the Flutter SDK
local binary_name = require("flutter-tools.utils.path").is_windows and "dart.bat" or "dart"
return path.join(flutter_sdk, "bin", binary_name)
local sdk = paths.dart_sdk or paths.flutter_sdk
return path.join(sdk, "bin", binary_name)
end

---Get paths for flutter and dart based on the binary locations
Expand Down Expand Up @@ -85,9 +86,9 @@ local function path_from_lookup_cmd(lookup_cmd, callback)
local result = j:result()
local flutter_sdk_path = result[1]
if flutter_sdk_path then
paths.dart_bin = _flutter_sdk_dart_bin(flutter_sdk_path)
paths.flutter_bin = path.join(flutter_sdk_path, "bin", "flutter")
paths.flutter_sdk = flutter_sdk_path
paths.flutter_bin = path.join(flutter_sdk_path, "bin", "flutter")
paths.dart_bin = _sdk_dart_bin(paths)
callback(paths)
else
paths = get_default_binaries()
Expand Down Expand Up @@ -116,7 +117,7 @@ function M.get(callback)
fvm = true,
}
_paths.dart_sdk = _dart_sdk_root(_paths)
_paths.dart_bin = _flutter_sdk_dart_bin(_paths.flutter_sdk)
_paths.dart_bin = _sdk_dart_bin(_paths)
return callback(_paths)
end
end
Expand All @@ -128,7 +129,7 @@ function M.get(callback)
flutter_sdk = _flutter_sdk_root(flutter_path),
}
_paths.dart_sdk = _dart_sdk_root(_paths)
_paths.dart_bin = _flutter_sdk_dart_bin(_paths.flutter_sdk)
_paths.dart_bin = _sdk_dart_bin(_paths)
return callback(_paths)
end

Expand All @@ -143,7 +144,7 @@ function M.get(callback)
if not _paths then
_paths = get_default_binaries()
_paths.dart_sdk = _dart_sdk_root(_paths)
if _paths.flutter_sdk then _paths.dart_bin = _flutter_sdk_dart_bin(_paths.flutter_sdk) end
if _paths.flutter_sdk then _paths.dart_bin = _sdk_dart_bin(_paths) end
end

return callback(_paths)
Expand Down