Skip to content

Commit b8fffa9

Browse files
Pass WATCH define in case of watch mode
1 parent b0c5a02 commit b8fffa9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/Fornax/Fornax.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let createFileWatcher dir handler =
6565
fileSystemWatcher.Deleted.Add handler
6666

6767
/// Adding handler to trigger websocket/live refresh
68-
let contentChangedHandler _ =
68+
let contentChangedHandler _ =
6969
signalContentChanged.Trigger(Choice<unit,Error>.Choice1Of2 ())
7070
signalContentChanged.Trigger(Choice<unit,Error>.Choice1Of2 ())
7171
fileSystemWatcher.Created.Add contentChangedHandler
@@ -152,7 +152,7 @@ let main argv =
152152
0
153153
| Some Build ->
154154
try
155-
do generateFolder cwd
155+
do generateFolder cwd false
156156
0
157157
with
158158
| FornaxGeneratorException message ->
@@ -167,7 +167,7 @@ let main argv =
167167

168168
let guardedGenerate () =
169169
try
170-
generateFolder cwd
170+
do generateFolder cwd true
171171
with
172172
| FornaxGeneratorException message ->
173173
printfn "%s%s%s" message Environment.NewLine waitingForChangesMessage

src/Fornax/Generator.fs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module EvaluatorHelpers =
1515

1616
let private sbOut = StringBuilder()
1717
let private sbErr = StringBuilder()
18-
let internal fsi () =
18+
let internal fsi (isWatch: bool) =
1919
let refs =
2020
ProjectSystem.FSIRefs.getRefs ()
2121
|> List.map (fun n -> sprintf "-r:%s" n)
@@ -29,8 +29,9 @@ module EvaluatorHelpers =
2929
let argv = [|
3030
yield! refs
3131
yield "--noframework"
32-
yield "/temp/fsi.exe";
33-
yield "--define:FORNAX"|]
32+
if isWatch then yield "--define:WATCH"
33+
yield "--define:FORNAX"
34+
yield "/temp/fsi.exe"; |]
3435
FsiEvaluationSession.Create(fsiConfig, argv, inStream, outStream, errStream)
3536
with
3637
| ex ->
@@ -180,12 +181,12 @@ module GeneratorEvaluator =
180181
|> Option.bind (tryUnbox<string>)
181182
|> function
182183
| Some s -> Ok (Encoding.UTF8.GetBytes s)
183-
| None ->
184+
| None ->
184185
result
185186
|> Option.bind (tryUnbox<byte[]>)
186187
|> function
187188
| Some bytes -> Ok bytes
188-
| None ->
189+
| None ->
189190
sprintf "HTML generator %s couldn't be compiled" generatorPath |> Error)
190191

191192
///`generatorPath` - absolute path to `.fsx` file containing the generator
@@ -200,7 +201,7 @@ module GeneratorEvaluator =
200201
result
201202
|> Option.bind (tryUnbox<(string * string) list>)
202203
|> function
203-
| Some files -> Ok (files |> List.map (fun (o, r) -> o, Encoding.UTF8.GetBytes r))
204+
| Some files -> Ok (files |> List.map (fun (o, r) -> o, Encoding.UTF8.GetBytes r))
204205
| None ->
205206
result
206207
|> Option.bind (tryUnbox<(string * byte[]) list>)
@@ -421,7 +422,7 @@ module Logger =
421422
let errorfn str = Printf.kprintf (fun s -> use c = consoleColor ConsoleColor.Red in printfn "%s" s) str
422423

423424
///`projectRoot` - path to the root of website
424-
let generateFolder (projectRoot : string) =
425+
let generateFolder (projectRoot : string) (isWatch: bool) =
425426

426427
let relative toPath fromPath =
427428
let toUri = Uri(toPath)
@@ -432,7 +433,7 @@ let generateFolder (projectRoot : string) =
432433
if projectRoot.EndsWith (string Path.DirectorySeparatorChar) then projectRoot
433434
else projectRoot + (string Path.DirectorySeparatorChar)
434435

435-
use fsi = EvaluatorHelpers.fsi ()
436+
use fsi = EvaluatorHelpers.fsi (isWatch)
436437
let sc = SiteContents ()
437438
let config =
438439
let configPath = Path.Combine(projectRoot, "config.fsx")

0 commit comments

Comments
 (0)