Created
September 1, 2018 08:31
-
-
Save alexey-detr/3e316f95793a1c80843480be15535608 to your computer and use it in GitHub Desktop.
Downloads most popular lodash dependents
This file contains 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 axios = require('axios'); | |
const cheerio = require('cheerio'); | |
const childProcess = require('child_process'); | |
(async () => { | |
const {data: npmListHtml} = await axios.get('https://www.npmjs.com/browse/depended/lodash'); | |
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(`https://www.npmjs.com/${npmPackageLink}`); | |
const $ = cheerio.load(npmPackageHtml); | |
const gitHubUrl = $('a.link.truncate').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