Skip to content

Commit

Permalink
refactor: remove unused run_npm from NodeInfo provider (#3725)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Mar 30, 2024
1 parent 00ee895 commit 2a2e29f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 37 deletions.
8 changes: 1 addition & 7 deletions docs/Core.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Defaults to `None`
**USAGE**

<pre>
node_toolchain(<a href="#node_toolchain-name">name</a>, <a href="#node_toolchain-headers">headers</a>, <a href="#node_toolchain-npm">npm</a>, <a href="#node_toolchain-npm_files">npm_files</a>, <a href="#node_toolchain-npm_path">npm_path</a>, <a href="#node_toolchain-run_npm">run_npm</a>, <a href="#node_toolchain-target_tool">target_tool</a>, <a href="#node_toolchain-target_tool_path">target_tool_path</a>)
node_toolchain(<a href="#node_toolchain-name">name</a>, <a href="#node_toolchain-headers">headers</a>, <a href="#node_toolchain-npm">npm</a>, <a href="#node_toolchain-npm_files">npm_files</a>, <a href="#node_toolchain-npm_path">npm_path</a>, <a href="#node_toolchain-target_tool">target_tool</a>, <a href="#node_toolchain-target_tool_path">target_tool_path</a>)
</pre>

Defines a node toolchain for a platform.
Expand Down Expand Up @@ -217,12 +217,6 @@ Defaults to `[]`

Defaults to `""`

<h4 id="node_toolchain-run_npm">run_npm</h4>

(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): A template file that allows us to execute npm

Defaults to `None`

<h4 id="node_toolchain-target_tool">target_tool</h4>

(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): A hermetically downloaded nodejs executable target for this target's platform.
Expand Down
5 changes: 0 additions & 5 deletions nodejs/private/nodejs_repo_host_os_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ def _nodejs_host_os_alias_impl(repository_ctx):
# Base BUILD file for this repository
repository_ctx.file("BUILD.bazel", """# Generated by nodejs_repo_host_os_alias.bzl
package(default_visibility = ["//visibility:public"])
# aliases for exports_files
alias(name = "run_npm.sh.template", actual = "@{node_repository}_{os_name}//:run_npm.sh.template")
alias(name = "run_npm.bat.template", actual = "@{node_repository}_{os_name}//:run_npm.bat.template")
# aliases for other aliases
alias(name = "node_bin", actual = "@{node_repository}_{os_name}//:node_bin")
alias(name = "npm_bin", actual = "@{node_repository}_{os_name}//:npm_bin")
alias(name = "npx_bin", actual = "@{node_repository}_{os_name}//:npx_bin")
Expand Down
18 changes: 0 additions & 18 deletions nodejs/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -300,27 +300,10 @@ CALL "%SCRIPT_DIR%\\{node}" %*
executable = True,
)

# This template file is used by the packager tool
# `yarn publish` is not ready for use under Bazel, see https://github.com/yarnpkg/yarn/issues/610
if repository_ctx.attr.platform.startswith("windows"):
run_npm = """
"{node}" "{script}" TMPL_args %*
"""
else:
run_npm = """
"{node}" "{script}" TMPL_args "$@"
"""

repository_ctx.file("run_npm.template", content = run_npm.format(
node = repository_ctx.path(node_entry),
script = repository_ctx.path(npm_script),
))

# Base BUILD file for this repository
build_content = """# Generated by node_repositories.bzl
package(default_visibility = ["//visibility:public"])
exports_files([
"run_npm.template",
"{node_entry}",
"{npm_entry}",
"{npx_entry}"
Expand Down Expand Up @@ -375,7 +358,6 @@ node_toolchain(
target_tool = ":node_bin",
npm = ":npm",
npm_files = [":npm_files"],
run_npm = ":run_npm.template",
headers = ":headers",
)
"""
Expand Down
7 changes: 0 additions & 7 deletions nodejs/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ May be empty if the target_tool_path points to a locally installed node binary."
"npm_files": """Files required in runfiles to make the npm executable available.
May be empty if the npm_path points to a locally installed npm binary.""",
"run_npm": """A template for a script that wraps npm.
On Windows, this is a Batch script, otherwise it uses Bash.""",
"headers": """\
(struct) Information about the header files, with fields:
* providers_map: a dict of string to provider instances. The key should be
Expand Down Expand Up @@ -96,7 +94,6 @@ def _node_toolchain_impl(ctx):
tool_files = tool_files,
npm_path = npm_path,
npm_files = npm_files,
run_npm = ctx.file.run_npm,
headers = struct(
providers_map = {
"CcInfo": ctx.attr.headers[CcInfo],
Expand Down Expand Up @@ -143,10 +140,6 @@ node_toolchain = rule(
doc = "Files required in runfiles to run npm.",
mandatory = False,
),
"run_npm": attr.label(
doc = "A template file that allows us to execute npm",
allow_single_file = True,
),
"headers": attr.label(
doc = "A cc_library that contains the Node/v8 header files for this target platform.",
),
Expand Down

0 comments on commit 2a2e29f

Please sign in to comment.