Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove utils.home_directory and use get_home_directory from Aspect bazel-lib utils instead #1606

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion npm/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ See https://bazel.build/docs/bzlmod#extension-definition

load("@bazel_features//:features.bzl", "bazel_features")
load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")
load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load("//npm:repositories.bzl", "npm_import", "pnpm_repository", _LATEST_PNPM_VERSION = "LATEST_PNPM_VERSION")
load("//npm/private:npm_translate_lock.bzl", "npm_translate_lock", "npm_translate_lock_lib")
load("//npm/private:npm_translate_lock_helpers.bzl", npm_translate_lock_helpers = "helpers")
Expand Down Expand Up @@ -107,7 +108,7 @@ def _npm_extension_impl(module_ctx):
(registries, npm_auth) = npm_translate_lock_helpers.get_npm_auth(npmrc, module_ctx.path(attr.npmrc), module_ctx.os.environ)

if attr.use_home_npmrc:
home_directory = utils.home_directory(module_ctx)
home_directory = bazel_lib_utils.home_directory(module_ctx)
if home_directory:
home_npmrc_path = "{}/{}".format(home_directory, ".npmrc")
home_npmrc = parse_npmrc(module_ctx.read(home_npmrc_path))
Expand Down
3 changes: 2 additions & 1 deletion npm/private/npm_translate_lock_state.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@aspect_bazel_lib//lib:base64.bzl", "base64")
load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")
load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load(":repository_label_store.bzl", "repository_label_store")
load(":npm_translate_lock_helpers.bzl", "helpers")
load(":utils.bzl", "INTERNAL_ERROR_MSG", "utils")
Expand Down Expand Up @@ -483,7 +484,7 @@ def _load_npmrc(priv, rctx, npmrc_path):

################################################################################
def _load_home_npmrc(priv, rctx):
home_directory = utils.home_directory(rctx)
home_directory = bazel_lib_utils.home_directory(rctx)
if not home_directory:
# buildifier: disable=print
print("""
Expand Down
4 changes: 0 additions & 4 deletions npm/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,6 @@ if [ ! -f $1 ]; then exit 42; fi
else:
fail(INTERNAL_ERROR_MSG)

def _home_directory(rctx):
return repo_utils.get_env_var(rctx, "HOME", None)

def _replace_npmrc_token_envvar(token, npmrc_path, environ):
# A token can be a reference to an environment variable
if token.startswith("$"):
Expand Down Expand Up @@ -463,7 +460,6 @@ utils = struct(
dicts_match = _dicts_match,
reverse_force_copy = _reverse_force_copy,
exists = _exists,
home_directory = _home_directory,
replace_npmrc_token_envvar = _replace_npmrc_token_envvar,
is_vendored_tarfile = _is_vendored_tarfile,
is_tarball_extension = _is_tarball_extension,
Expand Down