aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit.js
diff options
context:
space:
mode:
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);