Skip to content

Instantly share code, notes, and snippets.

@fmeyer
Forked from gabmontes/delete-all-my-gists.js
Last active March 20, 2021 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fmeyer/428e8153716d45a1b33f78bfc244a76a to your computer and use it in GitHub Desktop.
Save fmeyer/428e8153716d45a1b33f78bfc244a76a to your computer and use it in GitHub Desktop.
Gist cleanup
var async = require('async');
var GitHubApi = require('@octokit/rest');
var github = new GitHubApi({
version: '3.0.0',
});
github.authenticate({
type: 'oauth',
token: 'XXXXXXX'
})
async.waterfall([
function (callback) {
github.gists.getAll({}, callback);
},
function (gists, callback) {
// filter gists by properties as needed
async.each(gists.data, function (gist, callback) {
console.log("delete: " + gist.id)
github.gists.delete({
id: gist.id
}, callback);
}, callback);
}
], function (err) {
if (err) {
console.log('Execution failed: %s', err.message);
process.exit(1);
}
console.log('Done!');
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment