- Introduction
- CLI Installation
- Package Installation
- Protecting ENV comments and structure
- License - MIT License
Save a variable into .env
file with protect your other comments and variables
npm install env-save -g
$ env-save -h
Usage:
env-save [options] --VARIABLENAME=value [--VARIABLENAME2=value2 ...]
Options:
--VARIABLENAME=value Set .env variable
-e, --env Source file. default is ".env"
-v, --version Show the version number
-h, --help Show usage information
Examples:
env-save --NODE_ENV=production
env-save --PORT=3000 --USER=root --PASSWD=root --ENV=production
# We can also use these parameters "ENV", "VERSION" and "HELP"
# but not lowercase
env-save --VERSION=1.0.1 --ENV=production
Multiline Example: new line char: \n
env-save --PRIVATEKEY="---BEGIN RSA---\n...\nKh9NV\n-----END RSA---"
npm install env-save
const envSave = require('env-save')
envSave('MONGODB_URI','mongodb://localhost:27017/')
envSave('TOKEN','fdffd545fdggferdertrt')
envSave('DEBUG',true)
envSave('PORT',3000)
Before .env file
MY_NAME=shamanCoders
USER_ID=319817318 # for all mankind
TEST=4445
...
env-save --USER_ID=40015
After env-save
MY_NAME=shamanCoders
USER_ID=40015 # for all mankind
TEST=4445
...
Copyright (c) 2023-Now MiaJupiter Technology Inc.. All rights reserved. We are proud to be Open Source. For full details about the license, please check the LICENSE
file in the root directory of the source repository.