@clayton-state-university/whenv
v0.1.2
Published
A simple utility easily determine which value should be used based on which environment is being used.
Downloads
4
Keywords
Readme
whenv
A simple utility easily determine which value should be used based on which environment is being used.
It works by looking at the hostname of the system on which it is run and depends on the strings prod
, qa
, or dev
being contained in the hostname.
Examples
Callback
const Whenv = require('whenv')
let postUrl = new Whenv('http://produrl.domain.com', 'http://qaurl.domain.com', 'http://devurl.domain.com')
postUrl.setHostname('devscripts.domain.com') //NOTE: the hostname will be automatically determined, but you can override it with whenv.setHostname
postUrl.decide((url) => {
console.log(url) //http://devurl.domain.com
})
Promise
const Whenv = require('whenv')
let postUrl = new Whenv('http://produrl.domain.com', 'http://qaurl.domain.com', 'http://devurl.domain.com')
postUrl.setHostname('prodscripts.domain.com') //NOTE: the hostname will be automatically determined, but you can override it with whenv.setHostname
postUrl.decide()
.then(console.log) //http://produrl.domain.com