Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/torreslucas13/env-in-yaml
Simplest way to use environment variables in your .yml/.yaml files
https://github.com/torreslucas13/env-in-yaml
config configuration dotenv env environment-variables nodejs settings yaml yml
Last synced: 18 days ago
JSON representation
Simplest way to use environment variables in your .yml/.yaml files
- Host: GitHub
- URL: https://github.com/torreslucas13/env-in-yaml
- Owner: torreslucas13
- Created: 2022-06-25T18:55:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-28T18:55:58.000Z (over 2 years ago)
- Last Synced: 2024-11-15T22:14:40.751Z (about 1 month ago)
- Topics: config, configuration, dotenv, env, environment-variables, nodejs, settings, yaml, yml
- Language: TypeScript
- Homepage: https://github.com/torreslucas13/env-in-yaml
- Size: 94.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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