Created
January 5, 2019 22:36
-
-
Save sheerun/7af754ab0e73b0b05deaf435abe392a3 to your computer and use it in GitHub Desktop.
Revisions
-
sheerun created this gist
Jan 5, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ 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