1.1.1 โ€ข Published 1 year ago

@sensethenlove/env-write v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

๐Ÿ•‰ @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!

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago