Skip to content

Instantly share code, notes, and snippets.

@sheerun
Created January 5, 2019 22:36
Show Gist options
  • Save sheerun/7af754ab0e73b0b05deaf435abe392a3 to your computer and use it in GitHub Desktop.
Save sheerun/7af754ab0e73b0b05deaf435abe392a3 to your computer and use it in GitHub Desktop.
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