forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.js
executable file
·76 lines (61 loc) · 1.92 KB
/
repl.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
#!/usr/bin/env node
var p = require("child_process");
var path = require("path");
var ocamlVersion = "4.06.1";
var jscompDir = path.join(__dirname, "..", "jscomp");
var jsRefmtCompDir = path.join(__dirname, "..", "lib", ocamlVersion, "unstable");
var config = {
cwd: jscompDir,
encoding: "utf8",
stdio: [0, 1, 2],
shell: true
};
function e(cmd) {
console.log(`>>>>>> running command: ${cmd}`);
p.execSync(cmd, config);
console.log(`<<<<<<`);
}
if (!process.env.BS_PLAYGROUND) {
var defaultPlayground = `../../bucklescript-playground`;
console.warn(
`BS_PLAYGROUND env var unset, defaulting to ${defaultPlayground}`
);
process.env.BS_PLAYGROUND = defaultPlayground;
}
var playground = process.env.BS_PLAYGROUND;
function prepare() {
e(`hash hash js_of_ocaml 2>/dev/null || { echo >&2 "js_of_ocaml not found on path. Please install version 3.5.1 (with opam switch ${ocamlVersion}), and put it on your path."; exit 1; }
`);
e(
`ocamlc.opt -w -30-40 -no-check-prims -I ${jsRefmtCompDir} ${jsRefmtCompDir}/js_compiler.mli ${jsRefmtCompDir}/js_compiler.ml -o jsc.byte && js_of_ocaml jsc.byte -o exports.js`
);
e(`cp ../lib/js/*.js ${playground}/stdlib`);
e(`mv ./exports.js ${playground}`)
}
function prepublish() {
var mainPackageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')));
var packageJson = JSON.stringify(
{
name: "reason-js-compiler",
version: "0.0.1",
license: mainPackageJson.license,
description: mainPackageJson.description,
repository: mainPackageJson.repository,
author: mainPackageJson.author,
maintainers: mainPackageJson.maintainers,
bugs: mainPackageJson.bugs,
homepage: mainPackageJson.homepage,
main: "exports.js",
},
null,
2
);
fs.writeFileSync(
path.join(__dirname, "..", "_release", "package.json"),
packageJson,
{
encoding: "utf8"
}
);
}
prepare();