0.1.2 • Published 5 years ago

@clayton-state-university/whenv v0.1.2

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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