0.0.4 • Published 4 months ago

envimist v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

envimist

Applies minimist to process.env

lcov npm

Oh...

Status

Working draft

Install

yarn add envimist

Usage

import envimist from 'envimist'

const envs = envimist()

envs.path   // '/users/username/go/bin:/users/username/.kube:..'
envs.shell  // '/bin/zsh'
envs.user   // 'username'
// ...

You can provide some extra options to instruct the parser.

// Pass env records to parse. Defaults to process.env
const env = {
  FOO: 'false' 
}

// Regular minimist.Opts. Follow its docs for details
// https://github.com/minimistjs/minimist
const opts = {
  boolean: ['foo']
}
const envs = envimist(env, opts)

envs.foo // === false

To resolve variables as arrays, set splitting params:

const env = {
  FOO: 'bar,baz,qux',
  ABC: 'a,b,c',
  PATH: '/some/bin/path:/another/bin/dir'
}
const opts = {
  split: ['foo']
}

// You can also specify a custom separator:
const opts1 = {
  split: [['foo', ':']]
}
// Compbine diff vars with diff separators
const opts2 = {
  split: [['path', ':'], ['foo', 'abc', ',']]
}

envimist(env, opts2)
// {
//   foo: ['bar', 'baz', 'qux'],
//   abc: ['a', 'b', 'c'],
//   path: ['/some/bin/path', '/another/bin/dir'],
//   _: []
// }

License

MIT

0.0.4

4 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago

0.0.0

5 months ago