detectEnvironment
detectEnvironment(
env?):"local"|"development"|"ci"|"test"|"preview"|"production"|"agent"
Defined in: detect-environment.ts:19
The environment a process is running in: HOLOCRON_ENVIRONMENT, else ENVIRONMENT, when it names one (any case,
with the usual spellings such as production and staging), otherwise ci inside CI and local anywhere else.
Unlike environment.get() it reads only those two names (not ENV or NODE_ENV, which many tools set for their own
reasons) and never falls back to prod, so a laptop is never mistaken for production. They win over CI, so a deploy
job can say it is prod.
Parameters
Section titled “Parameters”Record<string, string | undefined> = process.env
Returns
Section titled “Returns”"local" | "development" | "ci" | "test" | "preview" | "production" | "agent"
Example
Section titled “Example”detectEnvironment({ HOLOCRON_ENVIRONMENT: "production" }); // "production"detectEnvironment({ ENVIRONMENT: "production" }); // "production"detectEnvironment({ CI: "true" }); // "ci"detectEnvironment({}); // "local"