Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ def _nodejs_binary_impl(ctx):
env_vars = ""

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means it doesn't get the right env when run directly in bazel-bin right? Or when run as a data dependency in the runfiles of something else?

]

_NODEJS_EXECUTABLE_ATTRS = {
Expand Down Expand Up @@ -467,8 +469,9 @@ nodejs_binary(
allow_files = True,
),
"env": attr.string_dict(
doc = """Specifies additional environment variables to set when the target is executed, subject to location
expansion.
doc = """
Specifies additional environment variables to set when the target is executed with `run` and `test`.
Subject to location expansion.
""",
default = {},
),
Expand Down