@@ -21,11 +21,17 @@ open Fake.IO.Globbing.Operators
21
21
open Fake.IO .FileSystemOperators
22
22
open Fake.JavaScript
23
23
24
+ let rootDir = Path.getFullName " ."
24
25
let srcDir = " ./src"
25
26
let outputDir = " ./output"
26
27
let distDir = " ./dist"
27
28
let testDir = " ./test"
28
29
30
+ let inDirectory dirName action =
31
+ Shell.cd dirName
32
+ action ()
33
+ Shell.cd rootDir
34
+
29
35
let run cmd dir args =
30
36
let result =
31
37
CreateProcess.fromRawCommandLine cmd args
@@ -131,8 +137,7 @@ module Test =
131
137
let build () =
132
138
for file in outputDir |> Shell.copyRecursiveTo true srcDir do
133
139
printfn " * copied to %s " file
134
- Shell.cd testDir
135
- dune " build"
140
+ inDirectory testDir <| fun () -> dune " build"
136
141
137
142
Target.create " TestJsooGenerateBindings" <| fun _ -> Test.Jsoo.generateBindings ()
138
143
Target.create " TestJsooBuild" <| fun _ -> Test.Jsoo.build ()
@@ -170,30 +175,33 @@ module Deploy =
170
175
let copyArtifacts () =
171
176
let mliDir = outputDir </> " test_jsoo"
172
177
let mlDir = testDir </> " jsoo/_build/default/src"
173
- let targets = [ " ts2ocaml_es" ; " ts2ocaml_dom" ; " ts2ocaml_webworker" ]
178
+ let targets = [ " ts2ocaml_min " ; " ts2ocaml_es" ; " ts2ocaml_dom" ; " ts2ocaml_webworker" ]
174
179
let targetDir = targetDir </> " src"
175
180
for target in targets do
181
+ Shell.rm ( targetDir </> $" {target}.mli" )
176
182
Shell.copyFile targetDir ( mliDir </> $" {target}.mli" )
183
+ Shell.rm ( targetDir </> $" {target}.ml" )
177
184
Shell.copyFile targetDir ( mlDir </> $" {target}.ml" )
178
185
179
186
let versionRegex =
180
187
String.getRegEx " \\ (version ((?>\\ w\\ .)*\\ w)\\ )"
181
188
182
189
let updateVersion () =
183
- File.read duneProject
184
- |> Seq.map ( fun line ->
185
- let result = versionRegex.Match line
190
+ duneProject |> File.applyReplace ( fun content ->
191
+ let result = versionRegex.Match content
186
192
if result.Success then
187
193
let oldVersion = result.Groups.[ 1 ]. Value
188
194
if oldVersion <> newVersion then
189
195
printfn $" * updating version in dist_jsoo/dune-project from '{oldVersion}' to '{newVersion}'."
190
- " (version $ {newVersion})"
196
+ content |> String.replace result.Value $ " (version {newVersion})"
191
197
else
192
198
printfn $" * version in dist_jsoo/dune-project not updated ('{newVersion}')."
193
- line
194
- else
195
- line)
196
- |> File.write false duneProject
199
+ content
200
+ else content
201
+ )
202
+
203
+ let testBuild () =
204
+ inDirectory targetDir <| fun () -> dune " build"
197
205
198
206
Target.create " Deploy" <| fun _ -> ()
199
207
Target.create " DeployOnly" <| fun _ -> ()
@@ -204,14 +212,24 @@ Target.create "DeployNpm" <| fun _ ->
204
212
Target.create " DeployJsoo" <| fun _ ->
205
213
Deploy.Jsoo.copyArtifacts ()
206
214
Deploy.Jsoo.updateVersion ()
215
+ Deploy.Jsoo.testBuild ()
207
216
208
217
" BuildOnly"
209
218
==> " DeployNpm"
210
219
==> " DeployJsoo"
211
220
==> " DeployOnly"
212
221
==> " Deploy"
213
222
223
+ " TestJsoo" ==> " DeployJsoo"
224
+
214
225
" Build" ==> " Deploy"
215
226
227
+ Target.create " All" ignore
228
+
229
+ " Build"
230
+ ==> " Test"
231
+ ==> " Deploy"
232
+ ==> " All"
233
+
216
234
// start build
217
235
Target.runOrDefault " Build"
0 commit comments