parent
fd1776850c
commit
305d1f58ba
@ -1,15 +1,36 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const owner = 'FonduemangVI';
|
const owner = 'FonduemangVI';
|
||||||
const repo = 'Guides';
|
const repo = 'Guides';
|
||||||
|
|
||||||
axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`)
|
async function updateContributors() {
|
||||||
.then(response => {
|
try {
|
||||||
const contributors = response.data.map(user => `- [@${user.login}](${user.html_url})`).join('\n');
|
const response = await axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`);
|
||||||
fs.writeFileSync('CONTRIBUTORS.md', `# Contributors\n\n${contributors}\n`);
|
|
||||||
})
|
if (!response.data || !Array.isArray(response.data)) {
|
||||||
.catch(error => {
|
throw new Error('Invalid response from GitHub API');
|
||||||
console.error(error);
|
}
|
||||||
process.exit(1);
|
|
||||||
});
|
const contributors = response.data.map(user => {
|
||||||
|
if (!user.login || !user.html_url || !user.avatar_url) {
|
||||||
|
throw new Error('Invalid user data from GitHub API');
|
||||||
|
}
|
||||||
|
return `|  | [@${user.login}](${user.html_url}) |`;
|
||||||
|
}).join('\n');
|
||||||
|
|
||||||
|
fs.writeFileSync('CONTRIBUTORS.md', `# Contributors\n\n| Avatar | Username |\n| --- | --- |\n${contributors}\n`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error updating contributors:', error.message);
|
||||||
|
|
||||||
|
if (error.response) {
|
||||||
|
console.error('Response status:', error.response.status);
|
||||||
|
console.error('Response data:', error.response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateContributors();
|
||||||
|
|
Loading…
Reference in new issue