mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-23 23:05:35 +03:00
24 lines
824 B
JavaScript
24 lines
824 B
JavaScript
const fs = require('fs');
|
|
const { execSync } = require("child_process");
|
|
|
|
const files = fs.readdirSync(__dirname);
|
|
const elmFiles = files.filter(file => file.endsWith(".elm"));
|
|
|
|
elmFiles.forEach(elmFile => {
|
|
const expectedOutput = fs.readFileSync(`${elmFile.slice(0, -4)}.txt`, 'utf8');
|
|
|
|
try {
|
|
const output = execSync(`elm make ./${elmFile}`, {encoding:"utf8", stdio: 'pipe', cwd: __dirname}).toString();
|
|
console.log(`ERROR: File ${elmFile} compiled, though it shouldn't have!`);
|
|
process.exit(1);
|
|
}
|
|
catch (error) {
|
|
if (error.stderr !== expectedOutput) {
|
|
console.log(`ERROR: File ${elmFile} failed to compile, but with the wrong error message!`);
|
|
console.log(`EXPECTED:\n\n${expectedOutput}\n\n`);
|
|
console.log(`GOT:\n\n${error.stderr}`);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
});
|