Skip to content

Commit

Permalink
fix: logic error in expand_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Feb 12, 2020
1 parent 3af3a0d commit 5beac84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions internal/common/expand_variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def expand_variables(ctx, s, outs = [], output_dir = False):
] if f]
else:
if s.find("$@") != -1 or s.find("$(@)") != -1:
if len(ctx.outputs.outs) > 1:
if len(outs) > 1:
fail("""$@ substitution may only be used with a single out
Upgrading rules_nodejs? Maybe you need to switch from $@ to $(RULEDIR)
See https://github.com/bazelbuild/rules_nodejs/releases/tag/0.42.0""")
additional_substitutions["@"] = ctx.outputs.outs[0].path
if len(ctx.outputs.outs) == 1:
output_dir = ctx.outputs.outs[0].dirname.split("/")
if len(outs) == 1:
additional_substitutions["@"] = outs[0].path
output_dir = outs[0].dirname.split("/")
else:
output_dir = rule_dir[:]

Expand Down
6 changes: 3 additions & 3 deletions internal/node/npm_package_bin.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def _inputs(ctx):
return depset(ctx.files.data, transitive = inputs_depsets).to_list()

def _impl(ctx):
if ctx.attr.output_dir and ctx.attr.outs:
if ctx.attr.output_dir and ctx.outputs.outs:
fail("Only one of output_dir and outs may be specified")
if not ctx.attr.output_dir and not ctx.attr.outs:
if not ctx.attr.output_dir and not ctx.outputs.outs:
fail("One of output_dir and outs must be specified")

args = ctx.actions.args()
Expand All @@ -50,7 +50,7 @@ def _impl(ctx):
outputs = ctx.outputs.outs

for a in ctx.attr.args:
args.add_all([expand_variables(ctx, e, outs = ctx.attr.outs, output_dir = ctx.attr.output_dir) for e in _expand_locations(ctx, a)])
args.add_all([expand_variables(ctx, e, outs = ctx.outputs.outs, output_dir = ctx.attr.output_dir) for e in _expand_locations(ctx, a)])

run_node(
ctx,
Expand Down

0 comments on commit 5beac84

Please sign in to comment.