From abf56a645494cdb99e5eba8d4078fda78ec4eba6 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Wed, 3 Apr 2024 13:53:18 -0700 Subject: [PATCH] feat: add get_home_directory to repo_utils (#809) --- docs/repo_utils.md | 18 ++++++++++++++++++ lib/private/repo_utils.bzl | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/docs/repo_utils.md b/docs/repo_utils.md index 50d80c6..a79b219 100644 --- a/docs/repo_utils.md +++ b/docs/repo_utils.md @@ -111,6 +111,24 @@ Find an environment variable in system. Doesn't %-escape the value! The environment variable value or the default if it is not set + + +## repo_utils.get_home_directory + +
+repo_utils.get_home_directory(rctx)
+
+ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| rctx |

-

| none | + + ## repo_utils.os diff --git a/lib/private/repo_utils.bzl b/lib/private/repo_utils.bzl index f2aac0b..e700c3e 100644 --- a/lib/private/repo_utils.bzl +++ b/lib/private/repo_utils.bzl @@ -55,6 +55,9 @@ def _get_env_var(rctx, name, default): return rctx.os.environ[name] return default +def _get_home_directory(rctx): + return _get_env_var(rctx, "HOME", None) + def _platform(rctx): """Returns a normalized name of the host os and CPU architecture. @@ -109,6 +112,7 @@ repo_utils = struct( is_linux = _is_linux, is_windows = _is_windows, get_env_var = _get_env_var, + get_home_directory = _get_home_directory, os = _os, platform = _platform, )