Skip to content

Commit

Permalink
fix: use default node url if the user happens to explicitly set []
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Apr 2, 2024
1 parent 6199ad0 commit e26ca53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/Core.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Defaults to `{}`

<h4 id="node_repositories-node_urls">node_urls</h4>

(*List of strings*): custom list of URLs to use to download NodeJS
(*List of strings*): List of URLs to use to download Node.js.

Each entry is a template for downloading a node distribution.

Expand Down
12 changes: 8 additions & 4 deletions nodejs/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ load("//nodejs/private:toolchains_repo.bzl", "PLATFORMS", "toolchains_repo")
# created by the module extension
DEFAULT_NODE_REPOSITORY = "nodejs"

# Default Node.js URL used as the default for node_urls
DEFAULT_NODE_URL = "https://nodejs.org/dist/v{version}/{filename}"

# Currently v18 is the "active" LTS release:
# https://nodejs.dev/en/about/releases/
# We can only change that in a major release of rules_nodejs,
Expand Down Expand Up @@ -92,10 +95,8 @@ By default, if this attribute has no items, we'll use a list of all public NodeJ
""",
),
"node_urls": attr.string_list(
default = [
"https://nodejs.org/dist/v{version}/{filename}",
],
doc = """custom list of URLs to use to download NodeJS
default = [DEFAULT_NODE_URL],
doc = """List of URLs to use to download Node.js.
Each entry is a template for downloading a node distribution.
Expand Down Expand Up @@ -166,6 +167,9 @@ def _download_node(repository_ctx):
return

node_urls = repository_ctx.attr.node_urls
if not node_urls:
# Go back the default if the user explicitly specifies []
node_urls = [DEFAULT_NODE_URL]

# Download node & npm
version_host_os = "%s-%s" % (node_version, host_os)
Expand Down

0 comments on commit e26ca53

Please sign in to comment.