@adonisjs/env
Version:
Environment variable manager for Node.js
54 lines (53 loc) • 1.66 kB
TypeScript
/**
* Environment editor for managing and modifying .env files.
* Provides functionality to load, edit, and save environment configuration files.
*/
export declare class EnvEditor {
#private;
/**
* Creates an instance of env editor and loads .env files
* contents.
*
* @param appRoot - The application root directory URL
* @returns Promise resolving to an EnvEditor instance
*/
static create(appRoot: URL): Promise<EnvEditor>;
/**
* Constructs a new EnvEditor instance
*
* @param appRoot - The application root directory URL
*/
constructor(appRoot: URL);
/**
* Loads .env files for editing. Only ".env" and ".env.example"
* files are picked for editing.
*
* @returns Promise that resolves when files are loaded
*/
load(): Promise<void>;
/**
* Add key-value pair to the dot-env files.
* If `withEmptyExampleValue` is true then the key will be added with an empty value
* to the `.env.example` file.
*
* @param key - The environment variable key
* @param value - The environment variable value
* @param withEmptyExampleValue - Whether to add empty value to .env.example file
*/
add(key: string, value: string | number | boolean, withEmptyExampleValue?: boolean): void;
/**
* Returns the loaded files as JSON
*
* @returns Array of file objects with contents and paths
*/
toJSON(): {
contents: string[];
path: string;
}[];
/**
* Save changes to the disk
*
* @returns Promise that resolves when files are saved
*/
save(): Promise<void>;
}