Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Created January 13, 2022 08:17
Show Gist options
  • Save Mulperi/9976ac41916001593ea652d966eb66fd to your computer and use it in GitHub Desktop.
Save Mulperi/9976ac41916001593ea652d966eb66fd to your computer and use it in GitHub Desktop.
Get all licenses from node_modules
from pathlib import Path
import json
for path in Path('node_modules').rglob('package.json'):
with open(path) as jsonFile:
try:
jsonObject = json.load(jsonFile)
except:
print("ERROR: json load failed")
jsonFile.close()
if jsonObject and "name" in jsonObject and "license" in jsonObject:
print("{}, {}".format(jsonObject["name"], jsonObject["license"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment