Skip to content

Commit 9bfd7df

Browse files
committed
add ability to warn on missing icons
1 parent c22a777 commit 9bfd7df

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ def build_argument_parser():
3535
help="Require a blocking_applications array for pkg installers.",
3636
)
3737
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
38-
parser.add_argument("--munki_repo", default='.',
39-
help="path to local munki repo defaults to '.'")
38+
parser.add_argument(
39+
"--munki_repo",
40+
default=".",
41+
help="path to local munki repo defaults to '.'"
42+
)
43+
parser.add_argument(
44+
"--warn_on_missing_icons",
45+
help="If added, this will only warn on missing icons.",
46+
action="store_true",
47+
default=False,
48+
)
4049
return parser
4150

4251

@@ -176,13 +185,19 @@ def main(argv=None):
176185
if not any(
177186
(
178187
pkginfo.get("icon_name"),
179-
os.path.isfile(os.path.join(args.munki_repo,
180-
"icons/{}.png".format(pkginfo["name"]))),
188+
os.path.isfile(
189+
os.path.join(
190+
args.munki_repo, "icons/{}.png".format(pkginfo["name"])
191+
)
192+
),
181193
pkginfo.get("installer_type") == "apple_update_metadata",
182194
)
183195
):
184-
print("{}: missing icon".format(filename))
185-
retval = 1
196+
if args.warn_on_missing_icons:
197+
print("WARNING: {}: missing icon".format(filename))
198+
else:
199+
print("{}: missing icon".format(filename))
200+
retval = 1
186201

187202
# Ensure uninstall method is set correctly if uninstall_script exists.
188203
if "uninstall_script" in pkginfo:

0 commit comments

Comments
 (0)