This package has been deprecated

Author message:

This project has been renamed. Install using @feelinglovelynow/env-write instead.

@sensethenlove/env-write
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

🕉 @sensethenlove/env-write

🙏 Description

  • Set keys & values in .env file w/ bash.
  • Helpful if using .env file in an environment where process 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 & value are added @ the end of the file.
  • Only works if each key in .env file is on its own line.

☯️ Install

pnpm add @sensethenlove/env-write

❤️ Example: package.json w/o optional bash

{
  "scripts": {
    "localEnv": "node node_modules/@sensethenlove/env-write/lib/index.js ENVIRONMENT=local HOST=http://localhost:5173 API=https://dev-api.example.com",
    "devEnv": "node node_modules/@sensethenlove/env-write/lib/index.js ENVIRONMENT=development HOST=https://dev.example.com API=https://dev-api.example.com",
    "mainEnv": "node node_modules/@sensethenlove/env-write/lib/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/@sensethenlove/env-write/lib/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"
  }
}

💖 Our helpful packages!

Package Sidebar

Install

npm i @sensethenlove/env-write

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

40.7 kB

Total Files

8

Last publish

Collaborators

  • sensethenlove