Skip to content

Commit f0e03ea

Browse files
chore: optimize function check_dependency_updates in check_modules.py
1 parent cc7be04 commit f0e03ea

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed

scripts/check_modules.py

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -572,27 +572,9 @@ def check_dependency_updates(module, module_directory_path):
572572
573573
Because this is so time-consuming, we only do this for modules with a small number of issues.
574574
575-
If there are only development updates, no issue will be created.
576575
"""
577576
package_json = Path(f"{module_directory_path}/package.json")
578-
prod_updates_list = []
579-
if len(module["issues"]) in [2, 3] and package_json.is_file():
580-
581-
prod_updates_string = (
582-
subprocess.run(
583-
f"ncu --cwd {module_directory_path} --dep prod",
584-
capture_output=True,
585-
shell=True,
586-
check=False
587-
)
588-
.stdout.decode()
589-
.rstrip()
590-
)
591-
prod_updates_list = prod_updates_string.splitlines()
592-
prod_updates_list = [
593-
line for line in prod_updates_string if "→" in line]
594-
595-
if len(prod_updates_list) > 0 or (len(module["issues"]) in [0, 1] and package_json.is_file()):
577+
if package_json.is_file() and len(module["issues"]) < 4:
596578

597579
updates_string = (
598580
subprocess.run(
@@ -613,19 +595,19 @@ def check_dependency_updates(module, module_directory_path):
613595
issue_text += f" -{update}\n"
614596
module["issues"].append(issue_text)
615597

616-
if len(module["issues"]) in [0, 1] and package_json.is_file():
617-
deprecation = deprecation_check.check_deprecated_packages(
618-
module_directory_path)
619-
if deprecation:
620-
module["issues"].append(deprecation)
621-
622-
if len(module["issues"]) in [0, 1] and package_json.is_file():
623-
eslint_issues = eslint_checks.eslint_check(module_directory_path)
624-
if eslint_issues:
625-
eslint_issues_text = "ESLint issues:\n"
626-
for issue in eslint_issues:
627-
eslint_issues_text += f" - {issue}\n"
628-
module["issues"].append(eslint_issues_text)
598+
if len(module["issues"]) < 3:
599+
deprecation = deprecation_check.check_deprecated_packages(
600+
module_directory_path)
601+
if deprecation:
602+
module["issues"].append(deprecation)
603+
604+
if len(module["issues"]) < 3:
605+
eslint_issues = eslint_checks.eslint_check(module_directory_path)
606+
if eslint_issues:
607+
eslint_issues_text = "ESLint issues:\n"
608+
for issue in eslint_issues:
609+
eslint_issues_text += f" - {issue}\n"
610+
module["issues"].append(eslint_issues_text)
629611

630612

631613
def check_branch_name(module, module_directory_path):

0 commit comments

Comments
 (0)