From 7467e671a95cdc4821dddbd9eaea212654aef12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20=C3=96hman?= Date: Mon, 19 Aug 2024 09:06:52 +0200 Subject: [PATCH] Use DOTNET_CLI_HOME for finding fantomas as global tool (Fixes #3104) (#3107) * Respect env variable DOTNET_CLI_HOME when looking for fantomas as a global tool * Update CHANGELOG.md --------- Co-authored-by: Florian Verdonck --- src/Fantomas.Client/CHANGELOG.md | 5 +++++ src/Fantomas.Client/FantomasToolLocator.fs | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Fantomas.Client/CHANGELOG.md b/src/Fantomas.Client/CHANGELOG.md index 142bc3a776..dd8bc75eb2 100644 --- a/src/Fantomas.Client/CHANGELOG.md +++ b/src/Fantomas.Client/CHANGELOG.md @@ -2,6 +2,11 @@ This is the changelog for the Fantomas.Client package specifically. It's distinct from that of the overall libraries and command-line tool. +## 0.9.1 - 2024-08-19 + +### Fixed +* Fantomas.Client does not respect DOTNET_CLI_HOME env variable. [#3104](https://github.com/fsprojects/fantomas/issues/3104) + ## 0.9.0 - 2023-02-24 * Fix JSON serialization of new cursor API. [#2778](https://github.com/fsprojects/fantomas/issues/2778) diff --git a/src/Fantomas.Client/FantomasToolLocator.fs b/src/Fantomas.Client/FantomasToolLocator.fs index c4303cfa3f..b2f00633b6 100644 --- a/src/Fantomas.Client/FantomasToolLocator.fs +++ b/src/Fantomas.Client/FantomasToolLocator.fs @@ -202,11 +202,16 @@ let createFor (startInfo: FantomasToolStartInfo) : Result - let userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + + let globalToolsPath = + match Option.ofObj (Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")) with + | Some s -> Path.Combine(s, "tools") + | None -> + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet", "tools") let fantomasExecutable = let fileName = if isWindows then "fantomas.exe" else "fantomas" - Path.Combine(userProfile, ".dotnet", "tools", fileName) + Path.Combine(globalToolsPath, fileName) let ps = ProcessStartInfo(fantomasExecutable) ps.Arguments <- "--daemon"