@mscs/environment
v0.1.2
Published
A library to load .env files and interact with the environment
Readme
@mscs/environment
A library to load and interact with the environment.
Installation
$ yarn add @mscs/environmentUsage
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.
Documentation
Currently, you have to build the documentation on your own.
$ git clone [email protected]:media-service-dev/environment.git
$ cd environment
$ yarn
$ yarn run docsImportant note
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.
