@@ -543,35 +543,35 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
543543def _generate_repositories (rctx , npm_imports , link_workspace ):
544544 repositories_bzl = []
545545
546- if len ( npm_imports ) > 0 :
546+ if npm_imports :
547547 repositories_bzl .append ("""load("@aspect_rules_js//npm:repositories.bzl", "npm_import")""" )
548548 repositories_bzl .append ("" )
549549
550550 repositories_bzl .append ("# Generated npm_import repository rules corresponding to npm packages in {}" .format (str (rctx .attr .pnpm_lock )))
551551 repositories_bzl .append ("# buildifier: disable=function-docstring" )
552552 repositories_bzl .append ("def npm_repositories():" )
553- if len ( npm_imports ) == 0 :
553+ if not npm_imports :
554554 repositories_bzl .append (" pass" )
555555 repositories_bzl .append ("" )
556556
557- for _ , _import in enumerate ( npm_imports ) :
558- repositories_bzl .append (_gen_npm_import (rctx , _import , link_workspace ))
557+ for npm_import in npm_imports :
558+ repositories_bzl .append (_gen_npm_import (rctx , npm_import , link_workspace ))
559559
560560 return repositories_bzl
561561
562562def _gen_npm_import (rctx , _import , link_workspace ):
563563 maybe_integrity = ("""
564564 integrity = "%s",""" % _import .integrity ) if _import .integrity else ""
565565 maybe_deps = ("""
566- deps = %s,""" % starlark_codegen_utils .to_dict_attr (_import .deps , 2 )) if len ( _import .deps ) > 0 else ""
566+ deps = %s,""" % starlark_codegen_utils .to_dict_attr (_import .deps , 2 )) if _import .deps else ""
567567 maybe_transitive_closure = ("""
568568 transitive_closure = %s,""" % starlark_codegen_utils .to_dict_list_attr (_import .transitive_closure , 2 )) if len (_import .transitive_closure ) > 0 else ""
569569 maybe_patch_tool = ("""
570570 patch_tool = "%s",""" % _import .patch_tool ) if _import .patch_tool else ""
571571 maybe_patches = ("""
572- patches = %s,""" % _import .patches ) if len ( _import .patches ) > 0 else ""
572+ patches = %s,""" % _import .patches ) if _import .patches else ""
573573 maybe_patch_args = ("""
574- patch_args = %s,""" % _import .patch_args ) if len ( _import .patches ) > 0 and len ( _import .patch_args ) > 0 else ""
574+ patch_args = %s,""" % _import .patch_args ) if _import .patches and _import .patch_args else ""
575575 maybe_custom_postinstall = ("""
576576 custom_postinstall = \" %s\" ,""" % _import .custom_postinstall ) if _import .custom_postinstall else ""
577577 maybe_lifecycle_hooks = ("""
@@ -583,7 +583,7 @@ def _gen_npm_import(rctx, _import, link_workspace):
583583 maybe_lifecycle_hooks_use_default_shell_env = ("""
584584 lifecycle_hooks_use_default_shell_env = True,""" ) if _import .lifecycle_hooks_use_default_shell_env else ""
585585 maybe_bins = ("""
586- bins = %s,""" % starlark_codegen_utils .to_dict_attr (_import .bins , 2 )) if len ( _import .bins ) > 0 else ""
586+ bins = %s,""" % starlark_codegen_utils .to_dict_attr (_import .bins , 2 )) if _import .bins else ""
587587 maybe_generate_bzl_library_targets = ("""
588588 generate_bzl_library_targets = True,""" ) if rctx .attr .generate_bzl_library_targets else ""
589589 maybe_commit = ("""
0 commit comments