excalidraw/scripts/changelog-check.js
David Luzar 34dcf998bd
docs: excalidraw package usage example tweaks (#2608)
Co-authored-by: Aakansha Doshi <monstershome@gmail.com>
2020-12-20 16:04:12 +01:00

35 lines
841 B
JavaScript

const { exec } = require("child_process");
const normalizePath = (path) => path.replace(/\\+/g, "/").trim().toLowerCase();
const IGNORED_PATHS = [
"src/excalidraw-app",
"packages/utils",
"CHANGELOG.md",
"README.md",
].map(normalizePath);
exec("git diff origin/master --cached --name-only", (error, stdout, stderr) => {
if (error || stderr) {
process.exit(1);
}
if (!stdout || stdout.includes("packages/excalidraw/CHANGELOG.md")) {
process.exit(0);
}
const changedFiles = stdout.trim().split("\n").map(normalizePath);
const excalidrawPackageFiles = changedFiles.filter((filename) => {
return (
filename.includes("src") &&
!IGNORED_PATHS.find((ignoredPath) => filename.includes(ignoredPath))
);
});
if (excalidrawPackageFiles.length) {
process.exit(1);
}
process.exit(0);
});