From c79e9980905d0ec01a9006a514ac40a234713587 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Sun, 2 Jul 2023 20:50:07 +0200 Subject: [PATCH] don't check packages repeatedly when running in recursive mode --- npm-manifest-check.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/npm-manifest-check.py b/npm-manifest-check.py index 6906624..b831603 100755 --- a/npm-manifest-check.py +++ b/npm-manifest-check.py @@ -105,7 +105,7 @@ def parse_actual_manifest(pkg, ver): return Manifest(name, version, dependencies, scripts) -def compare_manifests(pkg, brief=False, color=False, recursive=False): +def compare_manifests(pkg, brief=False, color=False, recursive=False, __checked_packages=[]): mismatch = False if pkg.reported_manifest.version != pkg.actual_manifest.version: mismatch = True @@ -178,9 +178,11 @@ def compare_manifests(pkg, brief=False, color=False, recursive=False): print(colors.END, end='') if recursive: + __checked_packages.append(pkg.name) for package in pkg.actual_manifest.dependencies: - print('Recursive: {}'.format(package)) - mismatch = compare_manifests(Package(package), brief=brief, color=color, recursive=True) or mismatch + if package in __checked_packages: + continue + mismatch = compare_manifests(Package(package), brief=brief, color=color, recursive=True, __checked_packages=__checked_packages) or mismatch return mismatch