# @totemish/env

> Nice and immutable NodeJS environment with .env and argv resolution.

Latest version **1.2.1** (published 2018-05-08) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @totemish/env
pnpm add @totemish/env
yarn add @totemish/env
bun add @totemish/env
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2018-05-08 |
| First published | 2018-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | priestine |
| Maintainers | priestine |
| Keywords | totemish, node, environment, env, process, argv, typescript |

## Links

- npm: https://www.npmjs.com/package/@totemish/env
- Repository: https://github.com/totemish/env
- Homepage: https://github.com/totemish/env#readme
- Issues: https://github.com/totemish/env/issues
- npm.io page: https://npm.io/package/@totemish/env

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.2.1 (latest) — 2018-05-08
- 1.2.0 — 2018-02-22
- 1.1.1 — 2018-02-16
- 1.1.0 — 2018-02-12
- 1.0.0 — 2018-02-12

## README

# Env

[![Core Build Status](https://travis-ci.org/totemish/env.svg?branch=master)](https://travis-ci.org/totemish/env)
[![codecov](https://img.shields.io/codecov/c/github/totemish/env.svg)](https://codecov.io/gh/totemish/env)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![downloads](https://img.shields.io/npm/dt/@totemish/env.svg)](https://www.npmjs.com/package/@totemish/env)
[![version](https://img.shields.io/npm/v/@totemish/env.svg)](https://www.npmjs.com/package/@totemish/env)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()

Totemish ENV wraps up your NodeJS `process.env` and `process.argv` into something convenient and immutable (sort of).

## Installation

```bash
npm i --save @totemish/env
```

## Usage

Simply instantiate the `Environment` class and you are good to go. Features:

#### `process.env`

It automatically eats your `.env` file if you haven't specified NODE_ENV to be equal to `production`.

```javascript
// NODE_ENV=production node index
import { Environment } from '@totemish/env';

const env = new Environment();

console.log(env.hasEnvKey('NODE_ENV')); // true
console.log(env.env.NODE_ENV); // 'production'
```

#### `process.argv`

* kwargs:

```javascript
// node index --a=b --b c -c=d -d f
import { Environment } from '@totemish/env';

const env = new Environment();

console.log(env.kwargs); // { a: 'b', b: 'c', c: 'd', d: 'e' }

console.log(env.hasKwargs()); // true
console.log(env.hasKwargKey('a')); // true
console.log(env.getKwarg('b')); // 'c'
```

* flags:

```javascript
// node index --flagged
import { Environment } from '@totemish/env';

const env = new Environment();

console.log(env.flags); // [ 'flagged' ]
console.log(env.hasFlags()); // true
console.log(env.hasFlag('flagged')); // true
```
* args:

```javascript
// node index myArg myArg2
import { Environment } from '@totemish/env';

const env = new Environment();

console.log(env.args); // [ 'myArg', 'myArg2' ]
console.log(env.hasArgs()); // true
console.log(env.hasArg('myArg')); // true
```

### Usage with @totemish/injector

```javascript
// node index --injectionSuccess
import { Environment } from '@totemish/env';
import { Container } from '@totemish/injector';

Container.register(Environment, 'env');

console.log(Container.get('env').hasFlag('injectionSuccess')); // true
```

## Links

* [API](https://totemish.github.io/framework)
* [Docs (Under Construction)](https://totemish.com/docs)
* [Tutorials (Under Construction)](https://totemish.com/tutorials)
* [Sample App (Under Construction)](https://github.com/totemish/sample-app)

---
_Source: https://npm.io/package/@totemish/env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
