Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vielhuber/from-env
🕶️ Get variables from env file in npm scripts. 🕶️
https://github.com/vielhuber/from-env
nodejs npm npm-scripts
Last synced: 19 days ago
JSON representation
🕶️ Get variables from env file in npm scripts. 🕶️
- Host: GitHub
- URL: https://github.com/vielhuber/from-env
- Owner: vielhuber
- Created: 2019-01-16T20:46:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-03T00:34:06.000Z (over 3 years ago)
- Last Synced: 2023-02-28T07:46:27.960Z (almost 2 years ago)
- Topics: nodejs, npm, npm-scripts
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🕶 from-env 🕶
from-env is helper script that makes environment variables from a local ``.env``-file inside command line statements available.
## installation
```bash
npm install --save-dev from-env
```## usage
``.env``
```.env
VARIABLE1=needs
VARIABLE2=have
VARIABLE3=variables
``````package.json``` (before)
```json
{
"scripts": {
"yo": "your-command --that needs --to have --some variables"
}
}
``````package.json``` (after)
```json
{
"scripts": {
"yo": "from-env your-command --that %VARIABLE1 --to %VARIABLE2 --some %VARIABLE3"
}
}
```### embedded variables replacement
To enable replacing variables that are not standlone:
`from-env --embedded-vars your-command --things thing1=%VARIABLE1 thing2=%VARIABLE2 --other $VARIABLE3`
or
`from-env your-command --things thing1=%VARIABLE1 thing2=%VARIABLE2 --other $VARIABLE3`
with
``.env``
```.env
FROM_ENV_EMBEDDED=true
```## alternative
this also works without any package (also on windows with wsl):
```package.json```
```json
{
"scripts": {
"yo": "from-env your-command --that $(grep VARIABLE1 .env | cut -d '=' -f2) --to $(grep VARIABLE2 .env | cut -d '=' -f2) --some $(grep VARIABLE3 .env | cut -d '=' -f2)"
}
}
```