Skip to content

Instantly share code, notes, and snippets.

@mathdroid
Created April 15, 2019 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathdroid/93dfcf3bd6d1892844d6d0aea6e1421e to your computer and use it in GitHub Desktop.
Save mathdroid/93dfcf3bd6d1892844d6d0aea6e1421e to your computer and use it in GitHub Desktop.
Delete gists above specific date
const got = require("got");
const DONT_ERASE_BELOW = "2019-04-08T21:45:03Z";
const del = async () => {
const res = await got("gists", {
baseUrl: "https://api.github.com",
headers: {
Authorization: `token ${token}`
}
});
const data = JSON.parse(res.body);
data.forEach(gist => {
if (gist.created_at > DONT_ERASE_BELOW) {
got.delete(`gists/${gist.id}`, {
baseUrl: "https://api.github.com",
headers: {
Authorization: `token ${token}`
}
});
}
});
};
del();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment