Skip to content

Instantly share code, notes, and snippets.

@vicradon
Last active April 28, 2020 21:19
Show Gist options
  • Save vicradon/8338c5729032438e7915c43ea41f2158 to your computer and use it in GitHub Desktop.
Save vicradon/8338c5729032438e7915c43ea41f2158 to your computer and use it in GitHub Desktop.
A script that will delete your private gists on github gist
const GitHub = require('github-api');
// basic auth
const gh = new GitHub({
username: __YOUR_USERNAME__,
password: __YOUR_PASSWORD__
})
// get the required user (you)
const user = gh.getUser(__YOUR_USERNAME__)
// get your gists, filter the neccessary and delete
user.listGists((err) => {
if (err) throw new Error("An error occured")
})
.then(res => {
// Get secret gist ids only
const data = res.data
.filter((x) => x.public === false)
.map((y) => y.id)
// Get the gist objects
gists = data.map((x) => gh.getGist(x))
gists.forEach((x) => {
// call the delete method on the gist objects
x.delete()
.then(() => console.log("Successfully deleted gist"))
.catch(err => console.error(err))
})
})
.catch(err => console.error(err))
@CeoFred
Copy link

CeoFred commented Apr 28, 2020

Interesting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment