Created
September 25, 2020 14:24
-
-
Save rudifa/f59c113d423f26291f824a162b71c98b to your computer and use it in GitHub Desktop.
In a node project, list scripts defined in package.json
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
#!/usr/bin/python3 | |
""" | |
In a node project, list scripts defined in package.json | |
@rudifa Rudi Farkas 2020 | |
""" | |
from os import path | |
import json | |
file = "package.json" | |
if path.exists(file): | |
f = open("package.json", "r") | |
ds = json.loads(f.read())["scripts"] | |
print('scripts:') | |
ml = max(list(map(len, ds.keys()))) | |
for k,v in ds.items(): | |
k += ' ' * (ml - len(k)) | |
print(f' {k} {v}') | |
else: | |
print(f'*** no such file: {file}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment