Skip to content

Commit

Permalink
Only write the targets file if it changed
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
vbfox authored and enricosada committed Oct 1, 2018
1 parent 08f347a commit 200d85a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/dotnet-proj-info/Inspect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,20 @@ let writeTargetFile log templates targetFileDestPath =
</Project>
"""

log (sprintf "writing helper target file in '%s'" targetFileDestPath)
File.WriteAllText(targetFileDestPath, targetFileTemplate.Trim())
let targetFileOnDisk =
if File.Exists(targetFileDestPath) then
try
Some (File.ReadAllText targetFileDestPath)
with
| _ -> None
else
None

let newTargetFile = targetFileTemplate.Trim()

if targetFileOnDisk <> Some newTargetFile then
log (sprintf "writing helper target file in '%s'" targetFileDestPath)
File.WriteAllText(targetFileDestPath, newTargetFile)

Ok targetFileDestPath

Expand Down

0 comments on commit 200d85a

Please sign in to comment.