3.0.0 • Published 7 years ago
sprawl v3.0.0
sprawl
About
sprawl sets and/or gets environment variables.
Documentation
Installation
Use sprawl as you would any CommonJS Node module.
Example
const sprawl = require('sprawl');or via destructuring
const { current, isProduction, seize } = require('sprawl');Properties
.current
Returns the current environment (via process.env.NODE_ENV)
Example
sprawl.current // => 'test'.environments
Returns an array of valid environments
Current valid environments
developmentteststagingproduction
Example
sprawl.environments // => [ 'development', 'production', 'staging', 'test' ].isProduction
Returns a boolean if the current environment is production
Example
sprawl.isProduction // => trueMethods
#seize(name, value)
Sets an environment variable.
Arguments
name—<String>value—<Number>,<Object>,<String>
Examples
sprawl.seize('JENNYS_PHONENUM', 8675309) // => '8675309'
sprawl.seize('JENNYS_RELEASE_DATE', { development: '1981' }) // => '1981'
sprawl.seize('JENNYS_RECORD_LABEL', 'Columbia Records') // => 'Columbia Records'Notes
- All
valuesare converted to<String> - If using an
<Object>as thevalue, only validenvironmentsare allowed as keys.
#seize(name)
Returns an environment variable.
Arguments
name—<String>
Example
sprawl.seize('JENNYS_PHONENUM') // => '8675309'