Skip to content

Commit a062708

Browse files
aspeddrocknitt
authored andcommitted
Remove generated_mocha_test.res if file exists
1 parent cecf214 commit a062708

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,21 @@ async function runTests() {
132132
console.log(`Skipping docstrings tests on ${process.platform}`);
133133
} else {
134134
console.log("Running runtime docstrings tests");
135+
136+
const generated_mocha_test_res = path.join("tests", "docstrings_examples", "generated_mocha_test.res")
137+
138+
// Remove `generated_mocha_test.res` if file exists
139+
if (fs.existsSync(generated_mocha_test_res)) {
140+
console.log(`Removing ${generated_mocha_test_res}`)
141+
fs.unlinkSync(generated_mocha_test_res)
142+
}
143+
135144
cp.execSync(`${rescript_exe} build`, {
136145
cwd: path.join(__dirname, "..", "tests/docstrings_examples"),
137146
stdio: [0, 1, 2],
138147
});
139148

149+
140150
// Generate rescript file with all tests `generated_mocha_test.res`
141151
cp.execSync(`node ${path.join("tests", "docstrings_examples", "DocTest.res.mjs")}`, {
142152
cwd: path.join(__dirname, ".."),
@@ -151,7 +161,7 @@ async function runTests() {
151161

152162
// Format generated_mocha_test.res
153163
console.log("Formatting generated_mocha_test.res")
154-
cp.execSync(`./cli/rescript format ${path.join("tests", "docstrings_examples", "generated_mocha_test.res")}`, {
164+
cp.execSync(`./cli/rescript format ${generated_mocha_test_res}`, {
155165
cwd: path.join(__dirname, ".."),
156166
stdio: [0, 1, 2],
157167
})

0 commit comments

Comments
 (0)