2021-10-16 09:57:21 +00:00
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
import { execSync } from "child_process";
|
|
|
|
|
|
|
|
|
|
const diff = execSync(`git diff --name-only origin/main HEAD`).toString();
|
|
|
|
|
|
2021-10-16 15:35:53 +00:00
|
|
|
|
const files = diff
|
|
|
|
|
.trim()
|
|
|
|
|
.split("\n")
|
|
|
|
|
.map((file) => file.trim())
|
|
|
|
|
.filter(Boolean);
|
2021-10-16 09:57:21 +00:00
|
|
|
|
|
|
|
|
|
console.log("ℹ️ Changed files:");
|
2021-10-16 15:35:53 +00:00
|
|
|
|
console.log(files.map((str) => ` - ${str}`).join("\n"));
|
2021-10-16 09:57:21 +00:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
console.log("⏳ Checking type errors..");
|
|
|
|
|
execSync("yarn tsc --noEmit", {});
|
|
|
|
|
|
|
|
|
|
console.log("😻 No errors!");
|
|
|
|
|
} catch (_err) {
|
|
|
|
|
const err = _err as any;
|
|
|
|
|
|
|
|
|
|
const output = err.stdout.toString() as string;
|
|
|
|
|
|
|
|
|
|
const filesWithTypeErrors = files.filter((file) => output.includes(file));
|
|
|
|
|
|
|
|
|
|
if (!filesWithTypeErrors.length) {
|
|
|
|
|
console.log(`🎉 You haven't introduced any new type errors!`);
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
console.log("❌ ❌ ❌ You seem to have touched files that have type errors ❌ ❌ ❌");
|
|
|
|
|
console.log("🙏 Please inspect the following files:");
|
|
|
|
|
console.log(filesWithTypeErrors.map((str) => ` - ${str}`).join("\n"));
|
|
|
|
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|