Skip to content

Instantly share code, notes, and snippets.

@sheerun
Created January 5, 2019 22:36
Embed
What would you like to do?
require 'open-uri'
require 'json'
require 'parallel'
packages = File.read('01.most-dependent-upon.md').scan(/\[([\w-]+)\]/m).to_a.map(&:first)
Parallel.each(packages) do |package|
begin
parsed = JSON.parse(open('https://registry.npmjs.org/' + package).read)
url = URI.parse(parsed['repository']['url'])
if url.host == 'github.com'
path = url.path.gsub(/.git$/, '')
manifest = 'https://raw.githubusercontent.com'+path+'/master/package.json'
puts manifest
File.write('packages/' + package + '.json', open(manifest).read)
end
rescue
puts "FAILED"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment