@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function getEnvVariable

    • retrieves the value of an environment variable on system runtimes (i.e. RUNTIME.DENO, RUNTIME.BUN, or RUNTIME.NODE). otherwise an error gets thrown on all other environments, since they do not support environment variables.

      Tip

      • environment variables are case-insensitive.
      • you will probably want to normalize path variables to posix path via pathToPosixPath.
      • if env_var = "" (an empty string) then undefined will always be returned on system-runtime environments.

      Parameters

      • runtime_enum: RUNTIME

        the runtime enum indicating which runtime should be used for querying the environment variable.

      • env_var: string

        the name of the environment variable to fetch.

      Returns undefined | string

      the environment variable's value.

      for js-workers, extensions, and web environments, an error gets thrown, as environment variables are not available.

      import { assertEquals } from "jsr:@std/assert"

      const my_path_env_var = getEnvVariable(identifyCurrentRuntime(), "path")!

      assertEquals(typeof my_path_env_var, "string")
      assertEquals(my_path_env_var.length > 0, true)