Runs a js_binary as a build action.
This macro wraps Aspect bazel-lib's run_binary (https://github.com/aspect-build/bazel-lib/blob/main/lib/run_binary.bzl) and adds attributes and features specific to rules_js's js_binary.
Macros and Functions
run_js_binary
Wrapper around @aspect_bazel_lib run_binary that adds convienence attributes for using a js_binary tool.
This rule does not require Bash native.genrule
.
Example usage (generated)
load("@aspect_rules_js//js:run_js_binary.bzl", "run_js_binary")
run_js_binary(
# Target name
name = "",
# The tool to run in the action
tool = None,
)
name
Target name
tool
The tool to run in the action.
Should be a js_binary rule. Use Aspect bazel-lib's run_binary (https://github.com/aspect-build/bazel-lib/blob/main/lib/run_binary.bzl) for other *_binary rule types.
env
Environment variables of the action.
Subject to $(location)
and make variable expansion.
srcs
Additional inputs of the action.
These labels are available for $(location)
expansion in args
and env
.
output_dir
Set to True if you want the output to be a directory.
Exactly one of outs
, output_dir
may be used.
If you output a directory, there can only be one output, which will be a
directory named the same as the target.
outs
Output files generated by the action.
These labels are available for $(location)
expansion in args
and env
.
args
Command line arguments of the binary.
Subject to $(location)
and make variable expansion.
chdir
Working directory to run the binary or test in, relative to the workspace.
This overrides the chdir value if set on the js_binary tool target.
By default, Bazel always runs in the workspace root.
To run in the directory containing the run_js_binary under the source tree, use
chdir = package_name()
(or if you're in a macro, use native.package_name()
).
To run in the output directory where the run_js_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.
You may need ../../
segments to re-relativize such paths to the new working directory.
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 outs
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 outs
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 outs
. Note that setting this will force the binary to exit 0.
If the binary creates outputs and these are declared, they must still be created
silent_on_success
produce no output on stdout nor stderr when program exits with status code 0.
This makes node binaries match the expected bazel paradigm.
copy_srcs_to_bin
When True, all srcs files are copied to the output tree that are not already there.
log_level
Set the logging level of the js_binary tool.
This overrides the log level set on the js_binary tool target.
kwargs
Additional arguments