Skip to content

Commit

Permalink
fsxc: refactoring to avoid unnecessary tuple
Browse files Browse the repository at this point in the history
The bin folder could be extracted anyway from the
.Directory property of the returned FileInfo instance.
  • Loading branch information
knocte committed Sep 5, 2024
1 parent ddc5d79 commit 2fb2d38
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fsxc/Fsxc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module Program =
let autogeneratedFile =
FileInfo(Path.Combine(binDir.FullName, autogeneratedFileName))

binDir, autogeneratedFile
autogeneratedFile

let ReadScriptContents(origScript: FileInfo) : List<LineAction> =

Expand Down Expand Up @@ -586,9 +586,11 @@ type FsiStub = { CommandLineArgs: array<string> }
let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }
"""

let binFolder, autogeneratedFile =
let autogeneratedFile =
GetAutoGenerationTargets origScript "fs"

let binFolder = autogeneratedFile.Directory

if not binFolder.Exists then
Directory.CreateDirectory binFolder.FullName |> ignore

Expand Down Expand Up @@ -707,7 +709,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }
(origScript: FileInfo)
(contents: List<LineAction>)
: FileInfo =
let _binFolder, projectFile =
let projectFile =
GetAutoGenerationTargets origScript "fsproj"

let rec iterate(lines: List<LineAction>) : unit =
Expand Down Expand Up @@ -829,7 +831,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }
#endif

let exitCode, exeTarget =
let _, exeTarget = GetAutoGenerationTargets script "exe"
let exeTarget = GetAutoGenerationTargets script "exe"
#if LEGACY_FRAMEWORK
let filesToCompile = getSourceFiles compilerInputs
let sourceFiles = String.Join(" ", filesToCompile)
Expand Down Expand Up @@ -947,9 +949,9 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }

let GetAlreadyBuiltExecutable
(exeTarget: FileInfo)
(binFolder: DirectoryInfo)
(lastWriteTimeOfSourceFile: DateTime)
: Option<FileInfo> =
let binFolder = exeTarget.Directory
if not binFolder.Exists then
None
elif binFolder.LastWriteTime < lastWriteTimeOfSourceFile then
Expand Down Expand Up @@ -1038,13 +1040,12 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }
Build parsedArgs generateArtifacts scriptContents verbose |> ignore
Environment.Exit 0

let binFolder, exeTarget =
let exeTarget =
GetAutoGenerationTargets parsedArgs.Script "exe"

let maybeExe =
GetAlreadyBuiltExecutable
exeTarget
binFolder
lastWriteTimeOfSourceFiles

if maybeExe.IsNone then
Expand Down

0 comments on commit 2fb2d38

Please sign in to comment.