Created
January 13, 2022 08:17
-
-
Save Mulperi/9976ac41916001593ea652d966eb66fd to your computer and use it in GitHub Desktop.
Get all licenses from node_modules
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
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