@@ -11,6 +11,7 @@ _ATTRS = {
1111 "chdir" : attr .string (),
1212 "configuration_env_vars" : attr .string_list (default = []),
1313 "data" : attr .label_list (allow_files = True , aspects = [module_mappings_aspect , node_modules_aspect ]),
14+ "env" : attr .string_dict (default = {}),
1415 "exit_code_out" : attr .output (),
1516 "link_workspace_root" : attr .bool (),
1617 "output_dir" : attr .bool (),
@@ -80,6 +81,7 @@ def _impl(ctx):
8081 arguments = [args ],
8182 configuration_env_vars = ctx .attr .configuration_env_vars ,
8283 chdir = expand_variables (ctx , ctx .attr .chdir ),
84+ env = ctx .attr .env ,
8385 stdout = ctx .outputs .stdout ,
8486 stderr = ctx .outputs .stderr ,
8587 exit_code_out = ctx .outputs .exit_code_out ,
@@ -93,7 +95,18 @@ _npm_package_bin = rule(
9395 attrs = _ATTRS ,
9496)
9597
96- def npm_package_bin (tool = None , package = None , package_bin = None , data = [], outs = [], args = [], output_dir = False , link_workspace_root = False , chdir = None , ** kwargs ):
98+ def npm_package_bin (
99+ tool = None ,
100+ package = None ,
101+ package_bin = None ,
102+ data = [],
103+ env = {},
104+ outs = [],
105+ args = [],
106+ output_dir = False ,
107+ link_workspace_root = False ,
108+ chdir = None ,
109+ ** kwargs ):
97110 """Run an arbitrary npm package binary (e.g. a program under node_modules/.bin/*) under Bazel.
98111
99112 It must produce outputs. If you just want to run a program with `bazel run`, use the nodejs_binary rule.
@@ -192,6 +205,7 @@ def npm_package_bin(tool = None, package = None, package_bin = None, data = [],
192205 args = ["/".join([".."] * _package_segments + ["$@"])],
193206 )
194207 ```
208+ env: specifies additional environment variables to set when the target is executed
195209 **kwargs: additional undocumented keyword args
196210 """
197211 if not tool :
@@ -205,6 +219,7 @@ def npm_package_bin(tool = None, package = None, package_bin = None, data = [],
205219 outs = outs ,
206220 args = args ,
207221 chdir = chdir ,
222+ env = env ,
208223 output_dir = output_dir ,
209224 tool = tool ,
210225 link_workspace_root = link_workspace_root ,
0 commit comments