Skip to content

Commit

Permalink
remove repo args + symlinks attr
Browse files Browse the repository at this point in the history
  • Loading branch information
christianscott committed Nov 15, 2023
1 parent b915935 commit f88e5c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
4 changes: 0 additions & 4 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,6 @@ Predefined genrule variables are not supported in this context.
default = Label("//internal/node:node_patches.js"),
allow_single_file = True,
),
"_repository_args": attr.label(
default = Label("@nodejs//:bin/node_repo_args.sh"),
allow_single_file = True,
),
"_require_patch_template": attr.label(
default = Label("//internal/node:require_patch.js"),
allow_single_file = True,
Expand Down
28 changes: 2 additions & 26 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,6 @@ and `{filename}` with the matching entry from the `node_repositories` attribute.
`bazel run @nodejs//:yarn_node_repositories` or `bazel run @nodejs//:npm_node_repositories install`.
If you use bazel-managed dependencies, you should omit this attribute.""",
),
"preserve_symlinks": attr.bool(
default = True,
doc = """Turn on --node_options=--preserve-symlinks for nodejs_binary and nodejs_test rules.
When this option is turned on, node will preserve the symlinked path for resolves instead of the default
behavior of resolving to the real path. This means that all required files must be in be included in your
runfiles as it prevents the default behavior of potentially resolving outside of the runfiles. For example,
all required files need to be included in your node_modules filegroup. This option is desirable as it gives
a stronger guarantee of hermeticity which is required for remote execution.""",
),
"vendored_node": attr.label(
allow_single_file = True,
doc = """the local path to a pre-installed NodeJS runtime.
Expand Down Expand Up @@ -465,11 +455,7 @@ def _prepare_node(repository_ctx):
npm_script_relative = npm_script if repository_ctx.attr.vendored_node else paths.relativize(npm_script, "bin")
yarn_script_relative = yarn_script if repository_ctx.attr.vendored_yarn else paths.relativize(yarn_script, "bin")

if repository_ctx.attr.preserve_symlinks:
node_args = "--preserve-symlinks"
else:
node_args = ""

node_args = "--preserve-symlinks"
# The entry points for node for osx/linux and windows
if not is_windows:
# Sets PATH and runs the application
Expand All @@ -494,14 +480,6 @@ SET PATH=%SCRIPT_DIR%;%PATH%
CALL "%SCRIPT_DIR%\\{node}" {args} %*
""".format(node = node_bin_relative, args = node_args))

# Shell script to set repository arguments for node used by nodejs_binary & nodejs_test launcher
repository_ctx.file("bin/node_repo_args.sh", content = """#!/usr/bin/env bash
# Immediately exit if any command fails.
set -e
# Generated by node_repositories.bzl
export NODE_REPOSITORY_ARGS="{args}"
""".format(args = node_args), executable = True)

# The entry points for npm for osx/linux and windows
# Runs npm using appropriate node entry point
# --scripts-prepend-node-path is set to false since the correct paths
Expand Down Expand Up @@ -667,8 +645,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%
package(default_visibility = ["//visibility:public"])
exports_files([
"run_npm.sh.template",
"run_npm.bat.template",
"bin/node_repo_args.sh",{node_bin_export}{npm_bin_export}{npx_bin_export}{yarn_bin_export}
"run_npm.bat.template",{node_bin_export}{npm_bin_export}{npx_bin_export}{yarn_bin_export}
"{node_entry}",
"{npm_entry}",
"{yarn_entry}",
Expand Down Expand Up @@ -734,7 +711,6 @@ package(default_visibility = ["//visibility:public"])
# aliases for exports_files
alias(name = "run_npm.sh.template", actual = "{node_repository}//:run_npm.sh.template")
alias(name = "run_npm.bat.template", actual = "{node_repository}//:run_npm.bat.template")
alias(name = "bin/node_repo_args.sh", actual = "{node_repository}//:bin/node_repo_args.sh")
# aliases for other aliases
alias(name = "node_bin", actual = "{node_repository}//:node_bin")
alias(name = "npm_bin", actual = "{node_repository}//:npm_bin")
Expand Down

0 comments on commit f88e5c3

Please sign in to comment.