@@ -10,6 +10,7 @@ _ATTRS = {
1010 "args" : attr .string_list (mandatory = True ),
1111 "configuration_env_vars" : attr .string_list (default = []),
1212 "data" : attr .label_list (allow_files = True , aspects = [module_mappings_aspect , node_modules_aspect ]),
13+ "exit_code_out" : attr .output (),
1314 "output_dir" : attr .bool (),
1415 "outs" : attr .output_list (),
1516 "stderr" : attr .output (),
@@ -64,6 +65,9 @@ def _impl(ctx):
6465 if ctx .outputs .stderr :
6566 tool_outputs .append (ctx .outputs .stderr )
6667
68+ if ctx .outputs .exit_code_out :
69+ tool_outputs .append (ctx .outputs .exit_code_out )
70+
6771 run_node (
6872 ctx ,
6973 executable = "tool" ,
@@ -73,6 +77,7 @@ def _impl(ctx):
7377 configuration_env_vars = ctx .attr .configuration_env_vars ,
7478 stdout = ctx .outputs .stdout ,
7579 stderr = ctx .outputs .stderr ,
80+ exit_code_out = ctx .outputs .exit_code_out ,
7681 )
7782
7883 return [DefaultInfo (files = depset (outputs + tool_outputs ))]
@@ -110,6 +115,9 @@ def npm_package_bin(tool = None, package = None, package_bin = None, data = [],
110115 subject to the same semantics as `outs`
111116 stdout: set to capture the stdout of the binary to a file, which can later be used as an input to another target
112117 subject to the same semantics as `outs`
118+ exit_code_out: set to capture the exit code of the binary to a file, which can later be used as an input to another target
119+ subject to the same semantics as `outs`. Note that setting this will force the binary to exit 0.
120+ If the binary creates outputs and these are declared, they must still be created
113121
114122 args: Command-line arguments to the tool.
115123
0 commit comments