diff --git a/internal/node/node.bzl b/internal/node/node.bzl index e6b7389e..d0dfe144 100755 --- a/internal/node/node.bzl +++ b/internal/node/node.bzl @@ -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 @@ -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), ] _NODEJS_EXECUTABLE_ATTRS = { @@ -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 = {}, ),