diff --git a/license_sh/commands/run_license_sh.py b/license_sh/commands/run_license_sh.py index bbd5f35..8d75480 100644 --- a/license_sh/commands/run_license_sh.py +++ b/license_sh/commands/run_license_sh.py @@ -68,7 +68,11 @@ def run_license_sh(arguments): dep_tree, license_map = runner.check() ignored_packages = ignored_packages_map[ProjectType.YARN.value] - filtered_dep_tree, licenses_not_found = get_dependency_tree_with_licenses( + ( + filtered_dep_tree, + licenses_not_found, + has_issues, + ) = get_dependency_tree_with_licenses( dep_tree, whitelist, ignored_packages=ignored_packages, get_full_tree=tree ) @@ -98,5 +102,4 @@ def run_license_sh(arguments): get_full_tree=tree, ) - has_issues: bool = filtered_dep_tree.height > 0 exit(1 if has_issues else 0) diff --git a/license_sh/helpers.py b/license_sh/helpers.py index 686f980..56b2849 100644 --- a/license_sh/helpers.py +++ b/license_sh/helpers.py @@ -1,6 +1,8 @@ from typing import Tuple, Set, List from anytree import PreOrderIter, LevelOrderIter, AnyNode +from anytree.exporter import DictExporter +from anytree.importer import DictImporter from license_expression import Licensing try: @@ -180,13 +182,14 @@ def filter_dep_tree(tree: AnyNode) -> AnyNode: Returns: AnyNode -- Filtered tree """ - for node in LevelOrderIter(tree): + treeCopy = DictImporter().import_(DictExporter().export(tree)) + for node in LevelOrderIter(treeCopy): node.children = filter( lambda subnode: subnode.subtree_problem or subnode.license_problem, node.children, ) - return tree + return treeCopy def get_dependency_tree_with_licenses( @@ -206,7 +209,7 @@ def get_dependency_tree_with_licenses( annotated_dep_tree, unknown_licenses = annotate_dep_tree( dep_tree, whitelist=whitelist, ignored_packages=ignored_packages ) - filtered_dependency_tree = ( - annotated_dep_tree if get_full_tree else filter_dep_tree(annotated_dep_tree) - ) - return filtered_dependency_tree, unknown_licenses + filtered_dependency_tree = filter_dep_tree(annotated_dep_tree) + has_issues = filtered_dependency_tree.height > 0 + dependency_tree = annotated_dep_tree if get_full_tree else filtered_dependency_tree + return dependency_tree, unknown_licenses, has_issues diff --git a/license_sh/version.py b/license_sh/version.py index b19b12e..f871089 100644 --- a/license_sh/version.py +++ b/license_sh/version.py @@ -1 +1 @@ -__version__ = "1.0.14" +__version__ = "1.0.15"