https://github.com/mrsteele/jsdotenv
A runnable env environment
https://github.com/mrsteele/jsdotenv
Last synced: 3 months ago
JSON representation
A runnable env environment
- Host: GitHub
- URL: https://github.com/mrsteele/jsdotenv
- Owner: mrsteele
- License: mit
- Created: 2018-05-21T19:24:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-21T20:04:17.000Z (about 7 years ago)
- Last Synced: 2024-12-28T08:40:56.293Z (5 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotenvjs
A runnable env environment
### About
Gone are the days of using flat `.env` files. This module will help you to build your env should you need that flexability.
### Example
Here is a simple example:
```js
// .env.js// Set your own defaults, whatever! Its your env anyways!
const env = {
NODE_ENV: 'develop'
}// Dynamically change thigns...
if (env.NODE_ENV === 'develop') {
env.LOGGING = true
}// Put all your vars into the exports!
module.exports = env
```And you can now just use it as expected:
```js
require('jsdotenv').config()if (process.env.LOGGING) {
console.log('Look Mom no hands!')
}
```### Installation
You can simply install:
```
npm i --save jsdotenv
```And then create a `.env.js` file in your root. After that include this package like you see above and you are ready to go!
### Additional Features
You can access this simple package with a simplified example, or use some of our additional Features.
##### parse
If you just wanna parse a file, try the following:
```js
const jsdotenv = require('jsdotenv')const parsed = jsdotenv.parse('/path/to/some/file.js')
console.log(parsed) // will be the evaluated parsed result.
```##### config
The example above is the minimalistic approach of the `config` function. You can also use advanced features as well like so (defaults in parenthesis):
```js
require('jsdotenv').config({
path: '.env.js' // The .env file to evaluate.
})
```### License
MIT