From 81e03df3a9768c854c78905725e809fdc3f540ea Mon Sep 17 00:00:00 2001 From: Bobby Date: Tue, 28 Jun 2022 03:27:32 +0530 Subject: Added hook for modifying readme --- hooks/pre-commit.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hooks/pre-commit.js (limited to 'hooks/pre-commit.js') diff --git a/hooks/pre-commit.js b/hooks/pre-commit.js new file mode 100644 index 00000000..c1b2cca0 --- /dev/null +++ b/hooks/pre-commit.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +// Open the readme file +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); -- cgit v1.2.3