0.0.2 • Published 5 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=productionorENV=prod - Using flags
PRODUCTION=true,PRODUCTION=yesorPROD=1
- Defining NODE_ENV or ENV:
Staging:
- Defining NODE_ENV or ENV:
NODE_ENV=stagingorENV=stg - Using flags
STAGING=true,STAGING=yesorSTG=1
- Defining NODE_ENV or ENV:
Testing:
- Defining NODE_ENV or ENV:
NODE_ENV=testingorENV=stg - Using flags
TESTING=true,TESTING=yesorTEST=1
- Defining NODE_ENV or ENV:
Development:
- Defining NODE_ENV or ENV:
NODE_ENV=developmentorENV=dev - Using flags
DEVELOPMENT=true,DEVEL=yesorDEV=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.jsAPI
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}