Last active
April 28, 2020 21:19
-
-
Save vicradon/8338c5729032438e7915c43ea41f2158 to your computer and use it in GitHub Desktop.
A script that will delete your private gists on github gist
This file contains hidden or 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
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting...