# env-in-yaml

> Simplest way to use environment variables in your .yml/.yaml files

Latest version **1.0.1** (published 2022-06-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install env-in-yaml
pnpm add env-in-yaml
yarn add env-in-yaml
bun add env-in-yaml
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-06-28 |
| First published | 2022-06-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lucas Torres |
| Maintainers | torreslucas |
| Keywords | env-in-yaml, env, yaml, yml, environment, configuration, config, dotenv, settings, node |

## Links

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

## Dependencies (1)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-06-28
- 1.0.0 — 2022-06-27

## README

# env-in-yaml

Simplest way to use environment variables in your .yml/.yaml files


### Instalation

```
# with npm
npm install env-in-yaml

# or with Yarn
yarn add env-in-yaml

```

### Usage and Example
First, you need to configure the .env file with the necessary variables, like the example below:

```
# .env
S3_BUCKET=myBucket
SECRET_KEY=ASBNAAYSTBAHAGSJA
```
Then configure and get the desired variable in your.yml/.yaml file. There are several ways and tools to do this, and I won't go into those details. Let's just assume that after setting up the .yaml file, you stored the `url` variable in the `url` constant

```yaml
# .yaml
URL="www.google-${ENV:S3_BUCKET}.com${ENV:SECRET_KEY}"

```
Note that the variable to be substituted is between the delimiters "${ENV:" and "}" .
You can override this setting by passing an `options` argument in the `envInYaml` function.

Once you get the variable you want in your .YML/.YAML file, just call the `envInYaml` function.

```ts
import { envInYaml } from 'env-in-yaml'

const url = 'www.google-${ENV:S3_BUCKET}.com${ENV:SECRET_KEY}'
const replaced = envInYaml(myVarFromYaml)
// output: www.google-myBucket.comASBNAAYSTBAHAGSJA

```

### Release History
- 1.0.0
  - Initial release
  
### Contributing
Any help is extremely welcome and I would love it! Feel free to submit your PR!
  
### Meta
Lucas Torres [@olucasdev](https://twitter.com/olucasdev)  
Follow me on Github and Twitter and get in touch !!  
I will love to talk about tech 😄!  
https://github.com/torreslucas13

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