From be382e516e9f0e4c46b7015c18e6d4e232ae6be4 Mon Sep 17 00:00:00 2001 From: Bobby Date: Tue, 28 Jun 2022 03:36:12 +0530 Subject: Modifying Readme before commit --- README.md | 2 +- hooks/pre-commit.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 54fca49f..716e877b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you would like to contribute to the website, please see the [contributing gui Below is the screenshot of how the website looks like right now. This screenshot is being updated programatically by [That Computer Scientist's Screenshot API](https://api.thatcomputerscientist.com/screenshot), and will update as I push more changes to the repository. -![Screenshot](https://api.thatcomputerscientist.com/screenshot?) +![Screenshot](https://api.thatcomputerscientist.com/screenshot?random=0.9081680163471533) ## Cloning, Installing, and Running diff --git a/hooks/pre-commit.js b/hooks/pre-commit.js index c1b2cca0..c4d3ff7c 100644 --- a/hooks/pre-commit.js +++ b/hooks/pre-commit.js @@ -5,7 +5,12 @@ const readme = fs.readFileSync("README.md", "utf8"); // Find the line which starts with "![Screenshot]" const screenshotLine = readme.split("\n").find(line => line.startsWith("![Screenshot]")); -screenshotLine.replace("![Screenshot]", `![Screenshot](https://api.thatcomputerscientist.com/screenshot?random=${Math.random()})`); -// Write the new line to the readme file -fs.writeFileSync("README.md", readme); +// Replace the line with the new screenshot +const newScreenshotLine = `![Screenshot](https://api.thatcomputerscientist.com/screenshot?random=${Math.random()})`; +const newReadme = readme.replace(screenshotLine, newScreenshotLine); + +// Write the new readme file +fs.writeFileSync("README.md", newReadme); + + -- cgit v1.2.3