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, )