Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@clayton-state-university/whenv

charlesread8ISC0.1.2

A simple utility easily determine which value should be used based on which environment is being used.

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