Skip to content

Commit

Permalink
refactor: update js_binary executable path to {name}_/{name} (#1690)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed May 20, 2024
1 parent 4013307 commit 3823cb0
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion e2e/worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ copy_file(
)

js_binary(
name = "worker_binary",
name = "worker",
data = [":copy_worker_js"],
entry_point = ":copy_dummy_worker",
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion e2e/worker/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pi_rule = rule(
"worker": attr.label(
executable = True,
cfg = "exec",
default = ":worker_binary",
default = ":worker",
),
},
)
2 changes: 1 addition & 1 deletion examples/coverage/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_test")

js_test(
name = "coverage_test",
name = "coverage",
data = [
"coverage.js",
"//:node_modules/@types/node",
Expand Down
6 changes: 4 additions & 2 deletions js/private/coverage/merger.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def _coverage_merger_impl(ctx):
# TODO(3.0): drop support for deprecated toolchain attributes
node_path = _deprecated_target_tool_path_to_short_path(nodeinfo.target_tool_path)

# Create launcher
bash_launcher = ctx.actions.declare_file(ctx.label.name)
# The '_' avoids collisions with another file matching the label name.
# For example, test and test/my.spec.ts. This naming scheme is borrowed from rules_go:
# https://github.com/bazelbuild/rules_go/blob/f3cc8a2d670c7ccd5f45434ab226b25a76d44de1/go/private/context.bzl#L144
bash_launcher = ctx.actions.declare_file("{}_/{}".format(ctx.label.name, ctx.label.name))
ctx.actions.expand_template(
template = ctx.file._launcher_template,
output = bash_launcher,
Expand Down
5 changes: 4 additions & 1 deletion js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ def _bash_launcher(ctx, nodeinfo, entry_point_path, log_prefix_rule_set, log_pre
"{{workspace_name}}": ctx.workspace_name,
}

launcher = ctx.actions.declare_file(ctx.label.name)
# The '_' avoids collisions with another file matching the label name.
# For example, test and test/my.spec.ts. This naming scheme is borrowed from rules_go:
# https://github.com/bazelbuild/rules_go/blob/f3cc8a2d670c7ccd5f45434ab226b25a76d44de1/go/private/context.bzl#L144
launcher = ctx.actions.declare_file("{}_/{}".format(ctx.label.name, ctx.label.name))
ctx.actions.expand_template(
template = ctx.file._launcher_template,
output = launcher,
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/image/checksum.expected
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
e6a04b6344eb21154508bf246ebead12d436313739c478978cd5763262491f98 js/private/test/image/cksum_app.tar
413693b1ad714b0dac59551b063bc33d0a4a680c9d48b71eba88c06a301cfc4a js/private/test/image/cksum_app.tar
7990126e5961588efd2af7cdccac3846dfffb8ca2e26206840df8c7a1c34c42e js/private/test/image/cksum_node_modules.tar
5 changes: 3 additions & 2 deletions js/private/test/image/custom_owner_app.listing
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image
-r-xr-xr-x 100/0 131 1970-01-01 00:00 app/js/private/test/image/bin
-r-xr-xr-x 100/0 136 1970-01-01 00:00 app/js/private/test/image/bin
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image
-r-xr-xr-x 100/0 23908 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_
-r-xr-xr-x 100/0 23908 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin
drwxr-xr-x 100/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin
-r-xr-xr-x 100/0 133 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin/node
-r-xr-xr-x 100/0 20 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/main.js
5 changes: 3 additions & 2 deletions js/private/test/image/default_app.listing
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image
-r-xr-xr-x 0/0 131 1970-01-01 00:00 app/js/private/test/image/bin
-r-xr-xr-x 0/0 136 1970-01-01 00:00 app/js/private/test/image/bin
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image
-r-xr-xr-x 0/0 23908 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_
-r-xr-xr-x 0/0 23908 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin
drwxr-xr-x 0/0 0 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin
-r-xr-xr-x 0/0 133 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin/node
-r-xr-xr-x 0/0 20 1970-01-01 00:00 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/main.js

0 comments on commit 3823cb0

Please sign in to comment.