Skip to content

Commit 6bd974a

Browse files
committed
Decouple compiler versions for testing with the actual rescript installation
1 parent 41596ef commit 6bd974a

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

compilers/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# compilers
2+
3+
This folder is needed to install additional rescript compiler versions for testing our documented source code on multiple compiler versions.
4+
5+
Our `scripts/test-examples.js` script will automatically install all package.json dependencies if it cannot find any compiler versions.

compilers/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compilers/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "compilers",
3+
"private": true,
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"dependencies": {
8+
"rescript-820": "npm:[email protected]"
9+
}
10+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"react-dom": "^16.12.0",
3030
"reason-promise": "^1.0.2",
3131
"reason-react": "^0.9.1",
32-
"rescript-820": "npm:bs-platform@^8.2.0",
3332
"remark-parse": "^7.0.1",
3433
"remark-slug": "^5.1.2",
3534
"remark-stringify": "^7.0.3",

scripts/test-examples.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ let tempFileNameRegex = /_tempFile\.res/g
88

99
// TODO: In the future we need to use the appropriate rescript version for each doc version variant
1010
// see the package.json on how to define another rescript version
11-
let bsc = path.join(__dirname, '..', 'node_modules', 'rescript-820', process.platform, 'bsc.exe')
11+
let compilersDir = path.join(__dirname, "..", "compilers")
12+
let bsc = path.join(compilersDir, 'node_modules', 'rescript-820', process.platform, 'bsc.exe')
13+
14+
const prepareCompilers = () => {
15+
if (fs.existsSync(bsc)) {
16+
return;
17+
}
18+
console.log("compilers not installed. Installing compilers...");
19+
child_process.execFileSync("npm", ['install'], {cwd: compilersDir})
20+
}
1221

1322
let parseFile = content => {
1423
if (!/```res (example|prelude|sig)/.test(content)) {
@@ -53,6 +62,10 @@ let postprocessOutput = (file, error) => {
5362
})
5463
}
5564

65+
66+
prepareCompilers();
67+
68+
console.log("Running tests...")
5669
fs.writeFileSync(tempFileName, '')
5770

5871
let success = true

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6853,11 +6853,6 @@ require-main-filename@^2.0.0:
68536853
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
68546854
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
68556855

6856-
"rescript-820@npm:bs-platform@^8.2.0":
6857-
version "8.3.2"
6858-
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-8.3.2.tgz#c307f1cc2d2397c3d088c7f3b62e9f493283cdcf"
6859-
integrity sha512-iOTi5JIlNPoCPq31NS9ET79FLyCpwTL2JZbgHz35LzY9Bch1iDtbBR3FVGhRbjphxelAP4fLlFONfUNp5Y3a5g==
6860-
68616856
resolve-from@^3.0.0:
68626857
version "3.0.0"
68636858
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"

0 commit comments

Comments
 (0)