0.0.2 • Published 3 years ago
yag-env v0.0.2
yag-env
Version 0.0.1, Copyright (c) 2016, Yassel Avila Gil
What is this?
Prepares the data defined via 'process.env' to be used in web applications or node packages.
License
Documentation
Environment definition
You can define the environment in the following ways:
Production (default):
- Defining NODE_ENV or ENV:
NODE_ENV=production
orENV=prod
- Using flags
PRODUCTION=true
,PRODUCTION=yes
orPROD=1
- Defining NODE_ENV or ENV:
Staging:
- Defining NODE_ENV or ENV:
NODE_ENV=staging
orENV=stg
- Using flags
STAGING=true
,STAGING=yes
orSTG=1
- Defining NODE_ENV or ENV:
Testing:
- Defining NODE_ENV or ENV:
NODE_ENV=testing
orENV=stg
- Using flags
TESTING=true
,TESTING=yes
orTEST=1
- Defining NODE_ENV or ENV:
Development:
- Defining NODE_ENV or ENV:
NODE_ENV=development
orENV=dev
- Using flags
DEVELOPMENT=true
,DEVEL=yes
orDEV=1
- Defining NODE_ENV or ENV:
Example
The following will define the development environment and will export some extra variables:
NODE_ENV=development ONE=1 TWO=2 OTHER=other EXPORTS=ONE,TWO node node-test.js
API
JavaScript:
var env = require('yag-env');
console.log(env.ENV); // 'development'
console.log(env.isProduction); // FALSE
console.log(env.isStaging); // FALSE
console.log(env.isTesting); // FALSE
console.log(env.isDevelopment); // TRUE
console.log(env.exported); // {ONE, TWO}
TypeScript:
import {default as env} from 'yag-env';
console.log(env.ENV); // 'development'
console.log(env.isProduction); // FALSE
console.log(env.isStaging); // FALSE
console.log(env.isTesting); // FALSE
console.log(env.isDevelopment); // TRUE
console.log(env.exported); // {ONE, TWO}