2.0.4 • Published 8 months ago

@battis/qui-cli.env v2.0.4

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
8 months ago

@battis/qui-cli.env

@battis/qui-cli Plugin: Standardized environment configuration

npm version Module type: ESM

Install

npm install @battis/qui-cli.env

Usage

import { Env } from '@battis/qui-cli.env';

// configure desired environment path
Env.configure({ path: '../../.env' });

// update .env
Env.set({ key: 'EXAMPLE', value: parseInt(process.env.EXAMPLE || '0') + 1 });

Configuration

export type Configuration = Plugin.Configuration & {
  root?: string;
  load?: boolean;
  path?: string;
};

root

Optional root for calculating relative paths to .env files. If undefined, falls back to the path defined by @battis/qui-cli.root.

load

Whether or not to load the .env file into process.env immediately. Defaults to true.

path

Path to desired .env file relative to root. Defaults to '.env';

Options

Env adds no user-configurable command line options.

Initialization

Env requires no initialization

API

import { Env } from '@battis/qui-cli.env';

Env.parse(file?)

Parse file (path relative to root, defaults to path if file is not defined) as a .env file and append to process.env. Passing load as true to configure() calls this immediately from configure().

Env.exists({key, file?}): boolean

Determine if a particular key exists in the specified .env file (defaults path if file is not defined).

Env.get({key, file?}): string | undefined

Get the string value (if present) of a particular key in a .env file (defaults to path if file is not defined). Returns undefined if the key is not present.

Env.set({key, value, comment?, file?}): void

Set the value of a particular key in the specified .env file (defaults to path if file is not defined). Optional comment can be inserted preceding the key in the file.

Env.remove({key, comment?, file?)

Remove a particular key from the specified .env file (defaults to path if file os not defined), optionally replacing the key with a comment.

2.0.4

8 months ago

2.0.3

9 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.0

9 months ago

0.8.6

9 months ago

0.8.5

9 months ago

0.8.4

9 months ago

0.8.3

9 months ago

0.8.2

12 months ago

0.8.1

12 months ago

0.8.0

12 months ago