forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.ml
28 lines (21 loc) · 734 Bytes
/
clean.ml
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
(* [@@@bs.config{no_export}] *)
module Fs = Node.Fs
let clean () =
Js.Undefined.iter [%node __dirname] (fun [@bs] dir ->
let bin_dir = Node.Path.join [|dir ; ".."; "bin"|] in
let files = Fs.readdirSync bin_dir in
Js.log ("cleaning now", files);
files |> Js.Array.forEach (fun [@bs] f ->
if not @@ Js.to_bool @@ Js.String.startsWith "bs" f
&& f <> ".gitignore"
then
let p = Node.Path.join [| bin_dir; f|] in
try
Js.log ("removing", p, "now");
Fs.unlinkSync p
with _ -> Js.log ("removing", p, "failure")
);
)
(* local variables: *)
(* compile-command: "bscc -c clean.ml" *)
(* end: *)