Skip to content

Commit

Permalink
Watch mode enhancement (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
laenas authored Mar 10, 2021
1 parent b4e5a33 commit 827f77c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Fornax/Fornax.fs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,20 @@ let main argv =
guardedGenerate ()

use watcher = createFileWatcher cwd (fun e ->
if not (e.FullPath.Contains "_public") && not (e.FullPath.Contains ".sass-cache") && not (e.FullPath.Contains ".git") && not (e.FullPath.Contains ".ionide") then
let pathDirectories =
Path.GetRelativePath(cwd,e.FullPath)
.Split(Path.DirectorySeparatorChar)

let shouldHandle =
pathDirectories
|> Array.exists (fun fragment ->
fragment = "_public" ||
fragment = ".sass-cache" ||
fragment = ".git" ||
fragment = ".ionide")
|> not

if shouldHandle then
let lastTimeWrite = File.GetLastWriteTime(e.FullPath)
match lastAccessed.TryFind e.FullPath with
| Some lt when Math.Abs((lt - lastTimeWrite).Seconds) < 1 -> ()
Expand Down

0 comments on commit 827f77c

Please sign in to comment.