@feelinglovelynow/env-write
v1.0.2
Published
Set keys and values in .env file w/ bash
Downloads
7
Maintainers
Readme
🕉 @feelinglovelynow/env-write
💎 Install
pnpm add @feelinglovelynow/env-write
🤓 Unit Tests
🙏 Description
- Set keys and values in
.env
file withbash
. - Helpful if using
.env
file in an environment whereprocess
is undefined. - If key is found in the
.env
file the new value is set. - If key is not found in the
.env
file the key and value are added @ the end of the file. - Only works if each key in
.env
file is on its own line.
💚 Example: package.json w/o optional bash
{
"scripts": {
"localEnv": "node node_modules/@feelinglovelynow/env-write/dist/index.js ENVIRONMENT=local HOST=http://localhost:5173 API=https://dev-api.example.com",
"devEnv": "node node_modules/@feelinglovelynow/env-write/dist/index.js ENVIRONMENT=development HOST=https://dev.example.com API=https://dev-api.example.com",
"mainEnv": "node node_modules/@feelinglovelynow/env-write/dist/index.js ENVIRONMENT=production HOST=https://app.example.com API=https://api.example.com"
}
}
💛 Example: .env
file below based on mainEnv
script above
# foo here before
ENVIRONMENT='production'
HOST='https://app.example.com'
API='https://api.example.com'
# bar remains
🧡 Example: Bash script (optional) (env.sh)
#!/bin/bash
node node_modules/@feelinglovelynow/env-write/dist/index.js ENVIRONMENT=$env HOST=$host API=$api
❤️ Example: package.json w/ optional bash
{
"scripts": {
"localEnv": "env=local host=http://localhost:5173 api=https://dev-api.example.com bash ./src/lib/scripts/env.sh",
"devEnv": "env=development host=https://dev.example.com api=https://dev-api.example.com bash ./src/lib/scripts/env.sh",
"mainEnv": "env=production host=https://app.example.com api=https://api.example.com bash ./src/lib/scripts/env.sh"
}
}
🎁 All Our Packages
- @feelinglovelynow/datetime-local: NPM ⋅ Github
- @feelinglovelynow/dgraph: NPM ⋅ Github
- @feelinglovelynow/env-write: NPM ⋅ Github
- @feelinglovelynow/get-form-entries: NPM ⋅ Github
- @feelinglovelynow/get-relative-time: NPM ⋅ Github
- @feelinglovelynow/global-style: NPM ⋅ Github
- @feelinglovelynow/jwt: NPM ⋅ Github
- @feelinglovelynow/loop-backwards: NPM ⋅ Github
- @feelinglovelynow/slug: NPM ⋅ Github
- @feelinglovelynow/svelte-catch: NPM ⋅ Github
- @feelinglovelynow/svelte-kv: NPM ⋅ Github
- @feelinglovelynow/svelte-loading-anchor: NPM ⋅ Github
- @feelinglovelynow/svelte-modal: NPM ⋅ Github
- @feelinglovelynow/svelte-turnstile: NPM ⋅ Github
- @feelinglovelynow/toast: NPM ⋅ Github