Skip to content

Instantly share code, notes, and snippets.

@filiptronicek
Last active November 24, 2022 18:06
Show Gist options
  • Save filiptronicek/fdfc009371401b9d63716759a90887f4 to your computer and use it in GitHub Desktop.
Save filiptronicek/fdfc009371401b9d63716759a90887f4 to your computer and use it in GitHub Desktop.
open-vsx.org extension hoarder - a script for downloading a lot of extensions
const fs = require("fs/promises");
const execSync = require("child_process").execSync;
const toDownload = 100;
const downloadFolder = "downloaded";
const getExtensions = async () => {
const openVsxResponse = await fetch(
`https://open-vsx.org/api/-/search?size=${toDownload}&sortBy=downloadCount&sortOrder=desc`
);
const openVsxData = await openVsxResponse.json();
const downloadLinks = openVsxData.extensions.map((ext) => ext.files.download);
const downloadFolderExists = await fs
.access(downloadFolder)
.then(() => true)
.catch(() => false);
if (!downloadFolderExists) {
await fs.mkdir(downloadFolder);
}
downloadLinks.forEach((link) => {
const fileExists = require("fs").existsSync(fileOutputLocation);
if (fileExists) {
console.info("Skipping")
return;
}
execSync(`curl -L ${link} -o ${fileOutputLocation}`);
console.info(`Downloaded ${link}`);
});
};
getExtensions();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment