Skip to content

Commit 963dc87

Browse files
authored
check file paths for probed environment variables for existence (#190)
1 parent 4be6ccf commit 963dc87

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"paket": {
6-
"version": "7.0.2",
6+
"version": "7.2.1",
77
"commands": [
88
"paket"
99
]
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"fantomas": {
24-
"version": "6.0.0-alpha-006",
24+
"version": "6.0.2",
2525
"commands": [
2626
"fantomas"
2727
]

src/Ionide.ProjInfo/Utils.fs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ module Paths =
3131
| "" -> None
3232
| other -> Some other
3333

34+
let private checkExistence (f: FileInfo) =
35+
if f.Exists then
36+
Some f
37+
else
38+
None
39+
3440
let private tryFindFromEnvVar () =
3541
potentialDotnetHostEnvVars
3642
|> List.tryPick (fun (envVar, transformer) ->
@@ -39,10 +45,9 @@ module Paths =
3945
|> existingEnvVarValue
4046
with
4147
| Some varValue ->
42-
Some(
43-
transformer varValue
44-
|> FileInfo
45-
)
48+
transformer varValue
49+
|> FileInfo
50+
|> checkExistence
4651
| None -> None
4752
)
4853

@@ -61,14 +66,9 @@ module Paths =
6166
||| StringSplitOptions.TrimEntries
6267
)
6368
|> Array.tryPick (fun d ->
64-
let fi =
65-
Path.Combine(d, dotnetBinaryName)
66-
|> FileInfo
67-
68-
if fi.Exists then
69-
Some fi
70-
else
71-
None
69+
Path.Combine(d, dotnetBinaryName)
70+
|> FileInfo
71+
|> checkExistence
7272
)
7373

7474

@@ -78,12 +78,9 @@ module Paths =
7878
let linuxPath = $"/usr/share/dotnet/{dotnetBinaryName}"
7979

8080
let tryFindFile p =
81-
let f = FileInfo p
81+
FileInfo p
82+
|> checkExistence
8283

83-
if f.Exists then
84-
Some f
85-
else
86-
None
8784

8885
if isWindows then
8986
tryFindFile windowsPath

0 commit comments

Comments
 (0)