@clayton-state-university/whenv

0.1.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @clayton-state-university/whenv

Weekly Downloads

1

Version

0.1.2

License

ISC

Unpacked Size

4.22 kB

Total Files

5

Last publish

Collaborators

  • jgoodson2
  • giangphan
  • shusainy
  • charlesread