aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit.js
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-06-28 03:36:12 +0530
committerBobby <[email protected]>2022-06-28 03:36:12 +0530
commitbe382e516e9f0e4c46b7015c18e6d4e232ae6be4 (patch)
tree34e04a19fc4c229bcd14b5d18f31292db96ef1d5 /hooks/pre-commit.js
parentd91bfefe7c1f917db8e669b7191a6705ac102102 (diff)
downloadthatcomputerscientist-be382e516e9f0e4c46b7015c18e6d4e232ae6be4.tar.xz
thatcomputerscientist-be382e516e9f0e4c46b7015c18e6d4e232ae6be4.zip
Modifying Readme before commit
Diffstat (limited to 'hooks/pre-commit.js')
-rw-r--r--hooks/pre-commit.js11
1 files changed, 8 insertions, 3 deletions
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);
+
+