-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.fsx
More file actions
63 lines (55 loc) · 1.78 KB
/
Copy pathbuild.fsx
File metadata and controls
63 lines (55 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#r "packages/FAKE/tools/FakeLib.dll"
open Fake
open System.IO
open System.Diagnostics
let buildDir = FullName "build"
let srcDir = FullName "src"
let appName = "FsTweet.Web"
let noFilter = (fun _ -> true)
let copyAssetsDir () =
let srcAssetsDir = Path.Combine(srcDir, appName, "assets")
let targetAssetsDir = Path.Combine(buildDir, "assets")
DeleteDir targetAssetsDir
CopyDir targetAssetsDir srcAssetsDir noFilter
let copyViewsDir () =
let srcViewsDir = Path.Combine(srcDir, appName, "views")
let targetViewsDir = Path.Combine(buildDir, "views")
DeleteDir targetViewsDir
CopyDir targetViewsDir srcViewsDir noFilter
Target "Clean" (fun _ -> CleanDirs [buildDir;])
Target "UI" (fun _ ->
copyAssetsDir()
copyViewsDir() )
let build () =
!! "src/FsTweet.sln"
|> MSBuildRelease buildDir "Build"
|> ignore
Target "Build" (fun _ -> build())
let runApp() =
let app = Path.Combine(buildDir, appName + ".exe")
if fileExists app then
execProcess (fun info -> info.FileName <- app) System.TimeSpan.MaxValue |> ignore
let onFileChange f =
killAllCreatedProcesses()
f()
runApp()
let handleWatcherEvents (e:System.IO.FileSystemEventArgs) =
let fileExtension = Path.GetExtension(e.FullPath)
match fileExtension with
| ".fs" -> onFileChange build
| ".liquid" -> onFileChange copyViewsDir
| ".css" | ".png" | ".js" -> onFileChange copyAssetsDir
| _ -> ()
Target "Watch" (fun _ ->
use watcher = new FileSystemWatcher(srcDir, "*.*", EnableRaisingEvents = true, IncludeSubdirectories = true)
watcher.Changed.Add(handleWatcherEvents)
watcher.Created.Add(handleWatcherEvents)
watcher.Renamed.Add(handleWatcherEvents)
runApp()
System.Console.ReadLine() |> ignore
)
"Clean"
==> "UI"
==> "Build"
==> "Watch"
RunTargetOrDefault "Watch"