Last active
June 4, 2021 15:22
-
-
Save albingroen/ff8866aa4b56ac9c00ca9eb6bb7d916b to your computer and use it in GitHub Desktop.
Delete multiple GitHub repos from your profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const axios = require("axios"); | |
// ADD THE NAME OF THE REPOS YOU WANT TO DELETE HERE | |
const repos = []; | |
// ADD YOUR GITHUB USERNAME HERE | |
const username = "" | |
// ADD YOUR GITHUB ACCESS TOKEN HERE | |
const token = "" | |
const main = () => { | |
repos.forEach((name) => { | |
try { | |
axios | |
.delete(`https://api.github.com/repos/${username}/${name}`, { | |
headers: { | |
Authorization: `bearer ${token}`, | |
}, | |
}) | |
.then(() => { | |
console.log(`Successfully deleted ${name}`); | |
}) | |
.catch((err) => { | |
console.log(`Failed to delete ${name}`); | |
console.log(err.message) | |
}); | |
} catch (err) { | |
console.log("Something went wrong"); | |
throw Error(err); | |
} | |
}); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment