From 32c003f55ec4200a02ca282d6b63dbe0af1d6655 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 11 Feb 2020 17:08:29 -0800 Subject: [PATCH] fix: logic error in expand_variables (#1631) --- internal/common/expand_variables.bzl | 8 ++++---- internal/node/npm_package_bin.bzl | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/common/expand_variables.bzl b/internal/common/expand_variables.bzl index b3e64d7e6e..013fd8c487 100644 --- a/internal/common/expand_variables.bzl +++ b/internal/common/expand_variables.bzl @@ -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[:] diff --git a/internal/node/npm_package_bin.bzl b/internal/node/npm_package_bin.bzl index ee86ada734..719f9b33c4 100644 --- a/internal/node/npm_package_bin.bzl +++ b/internal/node/npm_package_bin.bzl @@ -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() @@ -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,