This commit is contained in:
Axorax
2025-01-12 19:36:35 +06:00
parent a3f34ce930
commit 7dd5ef0a23
8 changed files with 750 additions and 674 deletions

View File

@@ -26,8 +26,56 @@ function create(fileName, emoji) {
console.log(`${fileName} execution time: ${Date.now() - startTime}ms`);
}
create("windows-only", "🪟");
create("macOS-only", "🍎");
create("linux-only", "🐧");
create("open-source-only", "🟢");
create("recommended-only", "");
function categorize() {
create("windows-only", "🪟");
create("macOS-only", "🍎");
create("linux-only", "🐧");
create("open-source-only", "🟢");
create("recommended-only", "⭐");
}
function format() {
const data = fs.readFileSync('README.md', 'utf8');
const updatedData = data
.split('\n')
.map(line => {
line = line.replace(/https:\/\/www\./g, 'https://');
if (line.startsWith('- [')) {
const parts = line.split(' - ');
if (parts.length >= 2) {
let description = parts[1];
description = description.replace(/^A\s+/i, '').replace(/^An\s+/i, '');
description = description.charAt(0).toUpperCase() + description.slice(1);
parts[1] = description;
line = parts.join(' - ');
}
}
return line;
})
.join('\n');
fs.writeFileSync('README.md', updatedData, 'utf8');
console.log('README.md has been formatted.');
}
function countLinks() {
const data = fs.readFileSync('README.md', 'utf8');
const linkCount = (data.match(/\[.*?\]\(https?:\/\/.*?\)/g) || []).length;
console.log(`Total links in README.md: \x1b[32m${linkCount}\x1b[0m`);
}
const args = process.argv.slice(2);
if (args.includes('--categorize')) {
categorize();
} else if (args.includes('--format')) {
format();
} else if (args.includes('--links')) {
countLinks();
} else {
console.log("Usage:");
console.log(" node index.js --categorize Run the categorize function");
console.log(" node index.js --format Format the README.md file");
console.log(" node index.js --links Count and display total links in README.md");
}