Skip to content

Commit 04d179e

Browse files
Match Bazel env attribute behaviour (#52)
1 parent 22be0dc commit 04d179e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

internal/node/node.bzl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ def _nodejs_binary_impl(ctx):
194194
env_vars = ""
195195

196196
# Add all env vars from the ctx attr
197+
expanded_env = {}
197198
for [key, value] in ctx.attr.env.items():
198-
env_vars += "export %s=%s\n" % (key, expand_location_into_runfiles(ctx, value, ctx.attr.data))
199+
expanded_env[key] = expand_location_into_runfiles(ctx, value, ctx.attr.data)
199200

200201
# While we can derive the workspace from the pwd when running locally
201202
# because it is in the execroot path `execroot/my_wksp`, on RBE the
@@ -361,6 +362,7 @@ fi
361362
# since this will be called from a nodejs_test, where the entrypoint is going to be the test file
362363
# we shouldn't add the entrypoint as a attribute to collect here
363364
coverage_common.instrumented_files_info(ctx, dependency_attributes = ["data"], extensions = ["js", "ts"]),
365+
RunEnvironmentInfo(expanded_env),
364366
]
365367

366368
_NODEJS_EXECUTABLE_ATTRS = {
@@ -467,8 +469,9 @@ nodejs_binary(
467469
allow_files = True,
468470
),
469471
"env": attr.string_dict(
470-
doc = """Specifies additional environment variables to set when the target is executed, subject to location
471-
expansion.
472+
doc = """
473+
Specifies additional environment variables to set when the target is executed with `run` and `test`.
474+
Subject to location expansion.
472475
""",
473476
default = {},
474477
),

0 commit comments

Comments
 (0)