aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit.js
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-06-28 03:27:32 +0530
committerBobby <[email protected]>2022-06-28 03:27:32 +0530
commit81e03df3a9768c854c78905725e809fdc3f540ea (patch)
tree37f4e5cb344ac6af47126a10f9eb5c6c07d978fd /hooks/pre-commit.js
parent60560011ce5cc3322d8eadb33033df6ed4b87c03 (diff)
downloadthatcomputerscientist-81e03df3a9768c854c78905725e809fdc3f540ea.tar.xz
thatcomputerscientist-81e03df3a9768c854c78905725e809fdc3f540ea.zip
Added hook for modifying readme
Diffstat (limited to 'hooks/pre-commit.js')
-rw-r--r--hooks/pre-commit.js11
1 files changed, 11 insertions, 0 deletions
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);