Skip to content

Commit d5730de

Browse files
authored
Merge pull request #876 from bloomberg/remove_ocaml_tools
add scripts to uninstall ocaml bins after installation
2 parents 6931a1d + 76e9ef1 commit d5730de

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

jscomp/others/js_string.ml

+2
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ external toLocaleLowerCase : t = "" [@@bs.send.pipe: t]
8181
external toUpperCase : t = "" [@@bs.send.pipe: t]
8282
external toLocaleUpperCase : t = "" [@@bs.send.pipe: t]
8383
external trim : t = "" [@@bs.send.pipe: t]
84+
85+
external startsWith : t -> Js.boolean = "" [@@bs.send.pipe:t]

scripts/clean.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
var Path = require("path");
4+
var Fs = require("fs");
5+
var Js_undefined = require("../lib/js/js_undefined");
6+
7+
Js_undefined.bind((__dirname), function (dir) {
8+
var bin_dir = Path.join(dir, "..", "bin");
9+
var files = Fs.readdirSync(bin_dir);
10+
console.log(/* tuple */[
11+
"cleaning now",
12+
files
13+
]);
14+
files.forEach(function (f) {
15+
if (!f.startsWith("bs") && f !== ".gitignore") {
16+
var p = Path.join(bin_dir, f);
17+
try {
18+
console.log(/* tuple */[
19+
"removing",
20+
p,
21+
"now"
22+
]);
23+
Fs.unlinkSync(p);
24+
return /* () */0;
25+
}
26+
catch (exn){
27+
console.log(/* tuple */[
28+
"removing",
29+
p,
30+
"failure"
31+
]);
32+
return /* () */0;
33+
}
34+
}
35+
else {
36+
return 0;
37+
}
38+
});
39+
return undefined;
40+
});
41+
42+
/* Not a pure module */

scripts/clean.ml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
[@@@bs.config{no_export}]
3+
module Fs = Node.Fs
4+
5+
6+
let _ =
7+
Js.Undefined.bind [%node __dirname] (fun [@bs] dir ->
8+
let bin_dir = Node.Path.join [|dir ; ".."; "bin"|] in
9+
let files = Fs.readdirSync bin_dir in
10+
Js.log ("cleaning now", files);
11+
files |> Js.Array.forEach (fun [@bs] f ->
12+
if not @@ Js.to_bool @@ Js.String.startsWith "bs" f
13+
&& f <> ".gitignore"
14+
then
15+
let p = Node.Path.join [| bin_dir; f|] in
16+
try
17+
Js.log ("removing", p, "now");
18+
Fs.unlinkSync p
19+
with _ -> Js.log ("removing", p, "failure")
20+
);
21+
Js.undefined
22+
)
23+
24+
25+
26+
(* local variables: *)
27+
(* compile-command: "bscc -c clean.ml" *)
28+
(* end: *)

scripts/postinstall.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ export PATH=$(pwd)/bin:$PATH
3030

3131
if [ $BS_TRAVIS_CI ]
3232
then
33-
cd jscomp && make travis-world-test && make install
33+
cd jscomp && make travis-world-test && make install && cd ..
3434
else
35-
cd jscomp && make world && make install
35+
cd jscomp && make world && make install && cd ..
3636
fi
37+
38+
# uninstall ocaml
39+
40+
node scripts/clean.js
41+

0 commit comments

Comments
 (0)