Skip to content

Commit

Permalink
refactor: restore check for js_library strip prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Oct 5, 2021
1 parent 6140040 commit 159e18a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions internal/js_library/js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,16 @@ def _link_path(ctx, all_files):
link_path += "/" + ctx.attr.strip_prefix

# Check that strip_prefix contains at least one src path
# check_prefix = "/".join([p for p in [ctx.label.package, ctx.attr.strip_prefix] if p])
# prefix_contains_src = False
# for file in all_files:
# if file.short_path.startswith(check_prefix):
# prefix_contains_src = True
# break
# if not prefix_contains_src:
# fail("js_library %s strip_prefix path does not contain any of the provided sources" % ctx.label)
check_prefix = "/".join([p for p in [ctx.label.workspace_name, ctx.label.package, ctx.attr.strip_prefix] if p])

prefix_contains_src = False
for file in all_files:
filepath = file.short_path[3:] if file.short_path.startswith("../") else file.short_path
if filepath.startswith(check_prefix):
prefix_contains_src = True
break
if not prefix_contains_src:
fail(" js_library %s strip_prefix path does not contain any of the provided sources" % ctx.label)

return link_path

Expand Down

0 comments on commit 159e18a

Please sign in to comment.