Skip to content

Commit

Permalink
Create index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoevans authored Jan 1, 2024
1 parent ef503de commit 80481a0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require('fs');

function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}

function updateReadme() {
// Read the current content of README.md
const readmeContent = fs.readFileSync('README.md', 'utf-8');

// Increment the keep alive count
const matches = readmeContent.match(/keep alive (\d+)/g);
const keepAliveCount = matches ? parseInt(matches[matches.length - 1].match(/\d+/)[0]) + 1 : 1;

// Generate a random string
const randomString = generateRandomString(8);

// Append the random string and the incremented count to README.md
const newContent = `${readmeContent}\n${randomString} keep alive ${keepAliveCount}\n`;

// Write the updated content back to README.md
fs.writeFileSync('README.md', newContent);

console.log(`Updated README.md with: ${randomString} keep alive ${keepAliveCount}`);
}

updateReadme();

0 comments on commit 80481a0

Please sign in to comment.