diff --git a/scripts/changelog-check.js b/scripts/changelog-check.js index dddb359a..46f53016 100644 --- a/scripts/changelog-check.js +++ b/scripts/changelog-check.js @@ -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); +}); diff --git a/src/packages/excalidraw/README.md b/src/packages/excalidraw/README.md index 3a6a0964..276bafd4 100644 --- a/src/packages/excalidraw/README.md +++ b/src/packages/excalidraw/README.md @@ -39,26 +39,19 @@ import "./styles.css"; export default function App() { const excalidrawRef = createRef(); - const onChange = (elements, state) => { - console.log(excalidrawRef.current); - console.log("Elements :", elements, "State : ", state); - }; - const [dimensions, setDimensions] = useState({ width: window.innerWidth, height: window.innerHeight, }); - const onResize = () => { - setDimensions({ - width: window.innerWidth, - height: window.innerHeight, - }); - }; - useEffect(() => { + const onResize = () => { + setDimensions({ + width: window.innerWidth, + height: window.innerHeight, + }); + }; window.addEventListener("resize", onResize); - return () => window.removeEventListener("resize", onResize); }, []); @@ -94,7 +87,6 @@ export default function App() { excalidrawRef.current.updateScene(sceneData); }; - const { width, height } = dimensions; return (