Skip to content

env ​

Environment variables.

Import

ts
import { Env } from "env";

Needs the "env" permission in thicket.json.

Env static class ​

ts
static class Env

Env.delete ​

ts
static delete(name: string): void

Remove an environment variable.

Parameters

  • name: The name of the variable to delete.

Env.entries ​

ts
static entries(): any

Get all environment variables as an array of [key, value] pairs.

Returns: An array of [name, value] tuples.

Env.get ​

ts
static get(name: string): any

Get an environment variable value.

Parameters

  • name: The name of the variable.

Returns: The variable's value, or null if not set.

Example

ts
import { Env } from "env";
const home: any = Env.get("HOME");
console.log(home != null); // true

Env.has ​

ts
static has(name: string): boolean

Check whether an environment variable is set.

Parameters

  • name: The name of the variable.

Returns: true if the variable exists, false otherwise.

Example

ts
import { Env } from "env";
if (Env.has("HOME")) {
    console.log("HOME is set");
}

Env.keys ​

ts
static keys(): any

Get all environment variable names.

Returns: An array of variable names.

Env.set ​

ts
static set(name: string, value: string): void

Set an environment variable.

Parameters

  • name: The name of the variable.
  • value: The value to set.

Generated from lang/types/env.d.tks in the ThicketScript repository.