fix: update js_run_binary chdir doc to reflect the default working directory of js_binary being the root of the output tree (#419)
diff --git a/docs/js_run_binary.md b/docs/js_run_binary.md index 2412c8b..03686d5 100755 --- a/docs/js_run_binary.md +++ b/docs/js_run_binary.md
@@ -40,7 +40,7 @@ | <a id="js_run_binary-outs"></a>outs | Output files generated by the action.<br><br>These labels are available for <code>$(location)</code> expansion in <code>args</code> and <code>env</code>. | <code>[]</code> | | <a id="js_run_binary-out_dirs"></a>out_dirs | Output directories generated by the action.<br><br>These labels are _not_ available for <code>$(location)</code> expansion in <code>args</code> and <code>env</code> since they are not pre-declared labels created via attr.output_list(). Output directories are declared instead by <code>ctx.actions.declare_directory</code>. | <code>[]</code> | | <a id="js_run_binary-args"></a>args | Command line arguments of the binary.<br><br>Subject to <code>$(location)</code> and make variable expansion. | <code>[]</code> | -| <a id="js_run_binary-chdir"></a>chdir | Working directory to run the binary or test in, relative to the workspace.<br><br>This overrides the chdir value if set on the js_binary tool target.<br><br>By default, Bazel always runs in the workspace root.<br><br>To run in the directory containing the js_run_binary under the source tree, use <code>chdir = package_name()</code> (or if you're in a macro, use <code>native.package_name()</code>).<br><br>To run in the output directory where the js_run_binary writes outputs, use <code>chdir = "$(RULEDIR)"</code><br><br>WARNING: this will affect other paths passed to the program, either as arguments or in configuration files, which are workspace-relative.<br><br>You may need <code>../../</code> segments to re-relativize such paths to the new working directory. | <code>None</code> | +| <a id="js_run_binary-chdir"></a>chdir | Working directory to run the build action in.<br><br>This overrides the chdir value if set on the js_binary tool target.<br><br>By default, js_binary tools run in the root of the output tree. For more context on why, please read the aspect_rules_js README https://github.com/aspect-build/rules_js/tree/dbb5af0d2a9a2bb50e4cf4a96dbc582b27567155#running-nodejs-programs.<br><br>To run in the directory containing the js_run_binary in the output tree, use <code>chdir = package_name()</code> (or if you're in a macro, use <code>native.package_name()</code>).<br><br>WARNING: this will affect other paths passed to the program, either as arguments or in configuration files, which are workspace-relative.<br><br>You may need <code>../../</code> segments to re-relativize such paths to the new working directory. | <code>None</code> | | <a id="js_run_binary-stdout"></a>stdout | set to capture the stdout of the binary to a file, which can later be used as an input to another target subject to the same semantics as <code>outs</code> | <code>None</code> | | <a id="js_run_binary-stderr"></a>stderr | set to capture the stderr of the binary to a file, which can later be used as an input to another target subject to the same semantics as <code>outs</code> | <code>None</code> | | <a id="js_run_binary-exit_code_out"></a>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 subject to the same semantics as <code>outs</code>. Note that setting this will force the binary to exit 0.<br><br>If the binary creates outputs and these are declared, they must still be created | <code>None</code> |
diff --git a/js/private/js_run_binary.bzl b/js/private/js_run_binary.bzl index 788de9f..5ef49af 100644 --- a/js/private/js_run_binary.bzl +++ b/js/private/js_run_binary.bzl
@@ -47,6 +47,7 @@ Args: name: Target name + tool: The tool to run in the action. Should be a js_binary rule. Use Aspect bazel-lib's run_binary @@ -75,18 +76,17 @@ Subject to `$(location)` and make variable expansion. - chdir: Working directory to run the binary or test in, relative to the workspace. + chdir: Working directory to run the build action in. This overrides the chdir value if set on the js_binary tool target. - By default, Bazel always runs in the workspace root. + By default, js_binary tools run in the root of the output tree. For more context on why, please read the + aspect_rules_js README + https://github.com/aspect-build/rules_js/tree/dbb5af0d2a9a2bb50e4cf4a96dbc582b27567155#running-nodejs-programs. - To run in the directory containing the js_run_binary under the source tree, use + To run in the directory containing the js_run_binary in the output tree, use `chdir = package_name()` (or if you're in a macro, use `native.package_name()`). - To run in the output directory where the js_run_binary writes outputs, use - `chdir = "$(RULEDIR)"` - WARNING: this will affect other paths passed to the program, either as arguments or in configuration files, which are workspace-relative.