A library to load and interact with the environment.
$ yarn add @mscs/environment
Short example:
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.
Currently, you have to build the documentation on your own.
$ git clone git@github.com:media-service-dev/environment.git
$ cd environment
$ yarn
$ yarn run docs
The parser for .env
-files and the environment file loading order logic was ported from Symfony.
Since Symfony is, for good reason, a registered trademark, please take note that we are in no way associated with the Symfony brand or the SensioLabs organization. Therefore, we don't represent or speak for any of them.