Skip to content

Commit 2034983

Browse files
webwarrior-wsknocte
authored andcommitted
Сlient: introduce File type
Introduce File type that checks existence of file on creation and is used in FSharpLintExecutableFile instead of string path.
1 parent 8db5dc6 commit 2034983

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/FSharpLint.Client/FSharpLintToolLocator.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ let private fsharpLintVersionOnPath () : (FSharpLintExecutableFile * FSharpLintV
141141
if File.Exists fsharpLint then Some fsharpLint
142142
else None)
143143
|> Seq.tryHead
144+
|> Option.bind File.From
144145

145146
fsharpLintExecutableOnPathOpt
146147
|> Option.bind (fun fsharpLintExecutablePath ->
147-
let processStart = ProcessStartInfo(fsharpLintExecutablePath)
148+
let processStart = ProcessStartInfo(File.Unwrap fsharpLintExecutablePath)
148149
processStart.Arguments <- "--version"
149150
processStart.RedirectStandardOutput <- true
150151
processStart.CreateNoWindow <- true
@@ -210,7 +211,7 @@ let createFor (startInfo: FSharpLintToolStartInfo) : Result<RunningFSharpLintToo
210211
ps.Arguments <- "--daemon"
211212
ps
212213
| FSharpLintToolStartInfo.ToolOnPath(FSharpLintExecutableFile executableFile) ->
213-
let ps = ProcessStartInfo(executableFile)
214+
let ps = ProcessStartInfo(File.Unwrap executableFile)
214215
ps.Arguments <- "--daemon"
215216
ps
216217

src/FSharpLint.Client/LSPFSharpLintServiceTypes.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ type FSharpLintResponseCode =
1313
| ErrDaemonCreationFailed = -1
1414
| OkCurrentDaemonVersion = 0
1515

16+
type File = private File of string
17+
with
18+
static member From (filePath: string) =
19+
if File.Exists(filePath) then
20+
filePath |> File |> Some
21+
else
22+
None
23+
24+
static member Unwrap(File f) = f
25+
1626
type FSharpLintVersion = FSharpLintVersion of string
17-
type FSharpLintExecutableFile = FSharpLintExecutableFile of string
27+
type FSharpLintExecutableFile = FSharpLintExecutableFile of File
1828
type Folder = private Folder of string
1929
with
2030
static member from (filePath: string) =

src/FSharpLint.Client/LSPFSharpLintServiceTypes.fsi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ type FSharpLintResponseCode =
88
| ErrDaemonCreationFailed = -1
99
| OkCurrentDaemonVersion = 0
1010

11+
type File = private File of string
12+
with
13+
static member From: string -> File option
14+
static member Unwrap: File -> string
15+
1116
type FSharpLintVersion = FSharpLintVersion of string
1217

13-
type FSharpLintExecutableFile = FSharpLintExecutableFile of string
18+
type FSharpLintExecutableFile = FSharpLintExecutableFile of File
1419

1520
type Folder = private Folder of string
1621
with

0 commit comments

Comments
 (0)