# path-env2

> Manipulate $PATH environment variable

Latest version **1.0.0** (published 2022-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install path-env2
pnpm add path-env2
yarn add path-env2
bun add path-env2
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-08-29 |
| First published | 2022-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 67.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hoàng Văn Khải |
| Maintainers | bluelovers |
| Keywords | PATH, env, env.PATH, create-by-yarn-tool, create-by-tsdx |

## Links

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

## Dependencies (1)

- [ts-type](https://npm.io/package/ts-type.md) >=2

## 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.0.0 (latest) — 2022-08-29

## README

# path-env

Manipulate [`$PATH`](https://en.wikipedia.org/wiki/PATH_(variable)
)-like environment variable

## Requirements

* Node.js ≥ 8.9.0

## Usage

**NOTE:**
  * Everything is **chainable**.

### Modifying `$PATH` and get its value

```javascript
import {pathString} from 'path-env'

const path = pathString()
  .append(['/append/bin'])
  .prepend(['/prepend/bin'])
  .surround(['/surround/bin'])
  .get.string()

console.log(path)
```

This will print `/surround/bin:/prepend/bin:...:/append/bin:/surround/bin` in POSIX systems.

### Modifying a `$PATH`-like and get its value

Modifying `$NODE_PATH`.

```javascript
import {pathString} from 'path-env'

const path = pathString('NODE_PATH')
  .append(['/append/node_modules'])
  .prepend(['/prepend/node_modules'])
  .surround(['/surround/node_modules'])
  .get.string()

console.log(path)
```

This will print `/surround/node_modules:/prepend/node_modules:...:/append/node_modules:/surround/node_modules` in POSIX systems.

### Modifying `$PATH`-like property of `env` object

You can also modify `$PATH`-like value directly from an `env`-like object.

**Signature:**

```typescript
import {pathEnv} from 'path-env'

const env = pathEnv() // equivalent to `const env = pathEnv(process.env, 'PATH')`
  .path.append(['/append/bin'])
  .path.prepend(['/prepend/bin'])
  .path.surround(['/surround/bin'])
  .get.env()

console.log(env)
```

**Result:** `env` will looks exactly like `process.env` except modified `PATH` property.

## License

[MIT](https://git.io/vhaEz) © [Hoàng Văn Khải](https://github.com/KSXGitHub)

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