Skip to content

Commit

Permalink
WIP: introduce File type
Browse files Browse the repository at this point in the history
  • Loading branch information
webwarrior-ws committed Jan 22, 2024
1 parent 86af13d commit 021f97d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/FSharpLint.Client/FSharpLintToolLocator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ let private fsharpLintVersionOnPath () : (FSharpLintExecutableFile * FSharpLintV
if File.Exists fsharpLint then Some fsharpLint
else None)
|> Seq.tryHead
|> Option.bind File.From

fsharpLintExecutableOnPathOpt
|> Option.bind (fun fsharpLintExecutablePath ->
let processStart = ProcessStartInfo(fsharpLintExecutablePath)
let processStart = ProcessStartInfo(File.Unwrap fsharpLintExecutablePath)
processStart.Arguments <- "--version"
processStart.RedirectStandardOutput <- true
processStart.CreateNoWindow <- true
Expand Down Expand Up @@ -210,7 +211,7 @@ let createFor (startInfo: FSharpLintToolStartInfo) : Result<RunningFSharpLintToo
ps.Arguments <- "--daemon"
ps
| FSharpLintToolStartInfo.ToolOnPath(FSharpLintExecutableFile executableFile) ->
let ps = ProcessStartInfo(executableFile)
let ps = ProcessStartInfo(File.Unwrap executableFile)
ps.Arguments <- "--daemon"
ps

Expand Down
12 changes: 11 additions & 1 deletion src/FSharpLint.Client/LSPFSharpLintServiceTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ type FSharpLintResponseCode =
| ErrDaemonCreationFailed = -1
| OkCurrentDaemonVersion = 0

type File = private File of string
with
static member From (filePath: string) =
if File.Exists(filePath) then
filePath |> File |> Some
else
None

static member Unwrap(File f) = f

type FSharpLintVersion = FSharpLintVersion of string
type FSharpLintExecutableFile = FSharpLintExecutableFile of string
type FSharpLintExecutableFile = FSharpLintExecutableFile of File
type Folder = private Folder of string
with
static member from (filePath: string) =
Expand Down
7 changes: 6 additions & 1 deletion src/FSharpLint.Client/LSPFSharpLintServiceTypes.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ type FSharpLintResponseCode =
| ErrDaemonCreationFailed = -1
| OkCurrentDaemonVersion = 0

type File = private File of string
with
static member From: string -> File option
static member Unwrap: File -> string

type FSharpLintVersion = FSharpLintVersion of string

type FSharpLintExecutableFile = FSharpLintExecutableFile of string
type FSharpLintExecutableFile = FSharpLintExecutableFile of File

type Folder = private Folder of string
with
Expand Down

0 comments on commit 021f97d

Please sign in to comment.