Skip to content

Commit

Permalink
Use DOTNET_CLI_HOME for finding fantomas as global tool (Fixes #3104) (
Browse files Browse the repository at this point in the history
…#3107)

* Respect env variable DOTNET_CLI_HOME when looking for fantomas as a global tool

* Update CHANGELOG.md

---------

Co-authored-by: Florian Verdonck <[email protected]>
  • Loading branch information
MikaelUmaN and nojaf authored Aug 19, 2024
1 parent f4738e0 commit 7467e67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Fantomas.Client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions src/Fantomas.Client/FantomasToolLocator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ let createFor (startInfo: FantomasToolStartInfo) : Result<RunningFantomasTool, P
ps.Arguments <- "fantomas --daemon"
ps
| FantomasToolStartInfo.GlobalTool ->
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"
Expand Down

0 comments on commit 7467e67

Please sign in to comment.