From 33ca3cc233086e7fcf187ce6b5b09528ecaa8262 Mon Sep 17 00:00:00 2001 From: FonduemangVI Date: Sun, 31 Mar 2024 23:01:05 +1100 Subject: [PATCH] testing --- .github/scripts/update-contributors.js | 51 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/.github/scripts/update-contributors.js b/.github/scripts/update-contributors.js index 437750b20..125f626e2 100644 --- a/.github/scripts/update-contributors.js +++ b/.github/scripts/update-contributors.js @@ -1,15 +1,36 @@ -const fs = require('fs'); -const axios = require('axios'); - -const owner = 'FonduemangVI'; -const repo = 'Guides'; - -axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`) - .then(response => { - const contributors = response.data.map(user => `- [@${user.login}](${user.html_url})`).join('\n'); - fs.writeFileSync('CONTRIBUTORS.md', `# Contributors\n\n${contributors}\n`); - }) - .catch(error => { - console.error(error); - process.exit(1); - }); + const fs = require('fs'); + const axios = require('axios'); + + const owner = 'FonduemangVI'; + const repo = 'Guides'; + + async function updateContributors() { + try { + const response = await axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`); + + if (!response.data || !Array.isArray(response.data)) { + throw new Error('Invalid response from GitHub API'); + } + + const contributors = response.data.map(user => { + if (!user.login || !user.html_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${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(); + \ No newline at end of file