Skip to content

Commit

Permalink
order list alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
imran110219 committed Oct 24, 2024
1 parent 5bfbbaf commit ba7b6a8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions generate-developer-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs');
const path = require('path');

// Define file paths
const readmePath = path.join(__dirname, 'README.md');
const jsonPath = path.join(__dirname, 'developer.json');

// Read README.md
const readmeContent = fs.readFileSync(readmePath, 'utf-8');

// Regex to match each developer block
const developerRegex = /### (.+?)\n- \*\*Email\*\*: (.+?)\n- \*\*LinkedIn\*\*: (.+?)\n- \*\*GitHub\*\*: (.+?)\n- \*\*Experience\*\*: (.+?)\n- \*\*Current Role\*\*: (.+?)\n- \*\*Skills\*\*: (.+?)\n- \*\*Location\*\*: (.+?)\n- \*\*Remote Work\*\*: (.+?)(?=\n\n|$)/g;

const developers = [];
let match;

// Loop through all matches of the regex
while ((match = developerRegex.exec(readmeContent)) !== null) {
const skills = match[7].split(',').map(skill => skill.trim()); // Split skills into an array
const remoteWork = match[9].trim().toLowerCase() === 'yes'; // Convert remote work string to boolean

developers.push({
name: match[1].trim(),
email: match[2].trim(),
linkedin: match[3].trim(),
github: match[4].trim(),
experience: match[5].trim(),
currentRole: match[6].trim(),
skills: skills,
location: match[8].trim(),
remoteWork: remoteWork
});
}

// Write to developer.json
fs.writeFileSync(jsonPath, JSON.stringify(developers, null, 2));

0 comments on commit ba7b6a8

Please sign in to comment.