changelog-check.js 888 B

12345678910111213141516171819202122232425262728293031323334
  1. const { exec } = require("child_process");
  2. const changeLogCheck = () => {
  3. exec(
  4. "git diff origin/master --cached --name-only",
  5. (error, stdout, stderr) => {
  6. if (error || stderr) {
  7. process.exit(1);
  8. }
  9. if (!stdout || stdout.includes("packages/excalidraw/CHANGELOG.md")) {
  10. process.exit(0);
  11. }
  12. const onlyNonSrcFilesUpdated = stdout.indexOf("src") < 0;
  13. if (onlyNonSrcFilesUpdated) {
  14. process.exit(0);
  15. }
  16. const changedFiles = stdout.trim().split("\n");
  17. const filesToIgnoreRegex = /src\/excalidraw-app|packages\/utils/;
  18. const excalidrawPackageFiles = changedFiles.filter((file) => {
  19. return file.indexOf("src") >= 0 && !filesToIgnoreRegex.test(file);
  20. });
  21. if (excalidrawPackageFiles.length) {
  22. process.exit(1);
  23. }
  24. process.exit(0);
  25. },
  26. );
  27. };
  28. changeLogCheck();