docs: excalidraw package usage example tweaks (#2608)

Co-authored-by: Aakansha Doshi <monstershome@gmail.com>
This commit is contained in:
David Luzar 2020-12-20 16:04:12 +01:00 committed by GitHub
parent 325d1bec91
commit 34dcf998bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 45 deletions

View file

@ -1,34 +1,34 @@
const { exec } = require("child_process");
const changeLogCheck = () => {
exec(
"git diff origin/master --cached --name-only",
(error, stdout, stderr) => {
if (error || stderr) {
process.exit(1);
}
const normalizePath = (path) => path.replace(/\\+/g, "/").trim().toLowerCase();
if (!stdout || stdout.includes("packages/excalidraw/CHANGELOG.md")) {
process.exit(0);
}
const IGNORED_PATHS = [
"src/excalidraw-app",
"packages/utils",
"CHANGELOG.md",
"README.md",
].map(normalizePath);
const onlyNonSrcFilesUpdated = stdout.indexOf("src") < 0;
if (onlyNonSrcFilesUpdated) {
process.exit(0);
}
exec("git diff origin/master --cached --name-only", (error, stdout, stderr) => {
if (error || stderr) {
process.exit(1);
}
const changedFiles = stdout.trim().split("\n");
const filesToIgnoreRegex = /src\/excalidraw-app|packages\/utils/;
if (!stdout || stdout.includes("packages/excalidraw/CHANGELOG.md")) {
process.exit(0);
}
const excalidrawPackageFiles = changedFiles.filter((file) => {
return file.indexOf("src") >= 0 && !filesToIgnoreRegex.test(file);
});
const changedFiles = stdout.trim().split("\n").map(normalizePath);
if (excalidrawPackageFiles.length) {
process.exit(1);
}
process.exit(0);
},
);
};
changeLogCheck();
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);
});