forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxwatcher_current.js
93 lines (73 loc) · 2.3 KB
/
xwatcher_current.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as Fs from "fs";
import * as Path from "path";
import * as Process from "process";
import * as Js_option from "../../lib/es6/js_option.js";
import * as Js_vector from "../../lib/es6/js_vector.js";
import * as Caml_option from "../../lib/es6/caml_option.js";
import * as Node_process from "../../lib/es6/node_process.js";
import * as Xwatcher_util from "./xwatcher_util.js";
import * as Child_process from "child_process";
Js_option.getExn(Caml_option.undefined_to_opt(typeof __dirname === "undefined" ? undefined : __dirname));
var cwd = Process.cwd();
var bsconfig = "bsconfig.json";
var root = Fs.existsSync(Path.join(cwd, bsconfig)) ? cwd : Xwatcher_util.findFile(cwd, Path.dirname(cwd), bsconfig);
console.log(" Root: " + (String(root) + " "));
var jscomp = Path.join(root, "jscomp");
var lock = Xwatcher_util.makeLock(/* () */0);
var events = Xwatcher_util.makeEventObj(/* () */0);
var command = "./watch-build.sh";
function exec(param) {
return Xwatcher_util.buildWithShell(command, events, lock, (function () {
return /* () */0;
}));
}
function watch(dir) {
return Xwatcher_util.makeWatcher(dir, (function (_event, fileName) {
if (fileName.endsWith(".ml") || fileName.endsWith(".mli") || fileName.endsWith(".cppo") || fileName.endsWith(".js") || fileName === "Makefile" || fileName === "Makefile.shared") {
return exec(/* () */0);
} else {
return 0;
}
}));
}
Node_process.putEnvVar("BS_VSCODE", "1");
var match = Process.argv.slice(2);
var exit = 0;
if (match.length !== 1) {
exit = 1;
} else {
var match$1 = match[0];
if (match$1 === "-build") {
Child_process.spawn(command, ( [ ]), ( { "stdio" : "inherit", "shell" : true }));
} else {
exit = 1;
}
}
if (exit === 1) {
Js_vector.iter((function (x) {
watch(Path.join(jscomp, x));
return /* () */0;
}), /* array */[
"core",
"syntax",
"ext",
"depends",
"others",
"ounit",
"ounit_tests",
"test",
"runtime",
"xwatcher",
"bsb",
"common",
"super_errors",
".",
"stubs",
"stdlib-406",
"napkin"
]);
exec(/* () */0);
}
export {
}
/* Not a pure module */