cal/scripts/ts-check-changed-files.ts
Alex Johansson a67813ee77
if you touch it you fix it (#967)
* wip

* add another

* check

* add ci job

* fix ci

* fix

* maybe

* maybs

* attempt

* test

* maybe

* another attempt

* try v2

* align with normal build

* this should break build

* Revert "this should break build"

This reverts commit 1ba44d18a1.

* tweaks

* prevent breaking on main

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-10-16 10:57:21 +01:00

38 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* eslint-disable @typescript-eslint/no-explicit-any */
import { execSync } from "child_process";
const diff = execSync(`git diff --name-only origin/main HEAD`).toString();
const files = diff.trim().split("\n");
console.log(" Changed files:");
console.log(
files
.filter(Boolean)
.map((str) => ` - ${str}`)
.join("\n")
);
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);
}