Created
April 15, 2019 04:25
-
-
Save mathdroid/93dfcf3bd6d1892844d6d0aea6e1421e to your computer and use it in GitHub Desktop.
Delete gists above specific date
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 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