Skip to content

Instantly share code, notes, and snippets.

Created September 1, 2018 08:31
What would you like to do?
Downloads most popular lodash dependents
const axios = require('axios');
const cheerio = require('cheerio');
const childProcess = require('child_process');
(async () => {
const {data: npmListHtml} = await axios.get('');
const $ = cheerio.load(npmListHtml);
const npmPackageLinks = $('section a').map((i, elem) => $(elem).attr('href')).get();
childProcess.execSync(`rm -rf ${__dirname}/packages`);
childProcess.execSync(`mkdir ${__dirname}/packages`);
for (const npmPackageLink of npmPackageLinks) {
console.log(`Loading NPM page ${npmPackageLink}`)
const {data: npmPackageHtml} = await axios.get(`${npmPackageLink}`);
const $ = cheerio.load(npmPackageHtml);
const gitHubUrl = $('').last().attr('href');
try {
console.log(`Cloning ${gitHubUrl}`);
childProcess.execSync(`git -C ${__dirname}/packages clone ${gitHubUrl}`);
} catch (e) {
console.log(`Can't clone ${gitHubUrl}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment