sprawl
v3.0.0
Published
Environment variable management
Downloads
2
Readme
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
development
test
staging
production
Example
sprawl.environments // => [ 'development', 'production', 'staging', 'test' ]
.isProduction
Returns a boolean
if the current environment is production
Example
sprawl.isProduction // => true
Methods
#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
values
are converted to<String>
- If using an
<Object>
as thevalue
, only validenvironments
are allowed as keys.
#seize(name)
Returns an environment variable.
Arguments
name
—<String>
Example
sprawl.seize('JENNYS_PHONENUM') // => '8675309'