Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/media-service-dev/environment

A library to load .env files and interact with the environment
https://github.com/media-service-dev/environment

dotenv environment library typescript

Last synced: 11 days ago
JSON representation

A library to load .env files and interact with the environment

Awesome Lists containing this project

README

        

# @mscs/environment

A library to load and interact with the environment.

## Installation

```shell script
$ yarn add @mscs/environment
```

## Usage

Short example:

```typescript
import { EnvironmentLoader, ProcessEnvironment } from "@mscs/environment";

async function runtime(){
const environment = new ProcessEnvironment();
const environmentLoader = new EnvironmentLoader(environment);

await environmentLoader.loadEnvironment(__dirname + '/../.env');

if(environment.has('FOO')){
const foo = environment.get("FOO");
// ...
}
}

runtime()
.catch(console.error);
```

*This example expect that you are in a root file of the `src` directory in your project.*

## Documentation

Currently, you have to build the documentation on your own.

```shell script
$ git clone [email protected]:media-service-dev/environment.git
$ cd environment
$ yarn
$ yarn run docs
```

# Important note

The parser for `.env`-files and the environment file loading order logic was ported from [Symfony](https://symfony.com/).

Since *Symfony* is, for good reason, a registered trademark, please take note that we are in no way associated with [the Symfony brand](https://symfony.com/) or the [SensioLabs](https://sensiolabs.com/) organization.
Therefore, we don't represent or speak for any of them.