aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit.js
blob: c4d3ff7c92fb4cbd98c7f6f52f979d02e3e5d421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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]"));

// 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);